]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs/test.cc: add assert for result of ceph_getxattr()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 10 May 2013 11:07:24 +0000 (13:07 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 10 May 2013 22:02:54 +0000 (00:02 +0200)
Check result of ceph_getxattr() before pass it as parameter to
strncmp(). Make sure it's not negative.

CID 739411 Argument cannot be negative (CWE-687)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/test/libcephfs/test.cc

index 6022fc5e06a96bc04abc46bb4591a26bebcd4466..7ecf536fb99a52d273f5978f886367e184032519 100644 (file)
@@ -436,6 +436,7 @@ TEST(LibCephFS, Xattrs) {
 
     char gxattrv[128];
     int alen = ceph_getxattr(cmount, test_xattr_file, p, (void *) gxattrv, 128);
+    ASSERT_LT(alen, 0);
     sprintf(xattrv, "testxattr%c", i);
     ASSERT_TRUE(!strncmp(xattrv, gxattrv, alen));