libcephfs/test.cc: add assert for result of ceph_getxattr()

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>
This commit is contained in:
Danny Al-Gaaf 2013-05-10 13:07:24 +02:00
parent 8d614665ec
commit 0c70e44630

View 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));