libgfapi: Fix pointer dereference before NULL check
Call to dict_keys_join dereferences xattr before it is checked for NULL. Restructured the function to check for NULL earlier and call dict_unref only when needed. BUG: 789278 CID: 1124826 Change-Id: I732fa304ad6f3b921c589832d13f73bbd36f589c Signed-off-by: Jose A. Rivera <jarrpa@redhat.com> Reviewed-on: http://review.gluster.org/6763 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
parent
4ac61e7354
commit
bb63256b7e
@ -2543,23 +2543,23 @@ out:
|
||||
int
|
||||
glfs_listxattr_process (void *value, size_t size, dict_t *xattr)
|
||||
{
|
||||
int ret = -1;
|
||||
int ret = -1;
|
||||
|
||||
if (!value || !size || !xattr)
|
||||
goto out;
|
||||
|
||||
ret = dict_keys_join (NULL, 0, xattr, NULL);
|
||||
|
||||
if (!value || !size)
|
||||
goto out;
|
||||
|
||||
if (size < ret) {
|
||||
ret = -1;
|
||||
errno = ERANGE;
|
||||
goto out;
|
||||
} else {
|
||||
dict_keys_join (value, size, xattr, NULL);
|
||||
}
|
||||
|
||||
dict_keys_join (value, size, xattr, NULL);
|
||||
dict_unref (xattr);
|
||||
|
||||
out:
|
||||
if (xattr)
|
||||
dict_unref (xattr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user