summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose A. Rivera <jarrpa@redhat.com>2014-01-22 21:51:42 -0600
committerVijay Bellur <vbellur@redhat.com>2014-01-24 01:41:59 -0800
commitbb63256b7ea1f186bbe3fae9040a6c191c9d6544 (patch)
tree0212f866e7bd18c3d55e62aef7c223038ce7b045
parent4ac61e7354d0c79e235e1b3be269a989ee0a83e6 (diff)
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>
-rw-r--r--api/src/glfs-fops.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 67d5616fe21..f27287b9d65 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -2543,23 +2543,23 @@ out:
int
glfs_listxattr_process (void *value, size_t size, dict_t *xattr)
{
- int ret = -1;
-
- ret = dict_keys_join (NULL, 0, xattr, NULL);
+ int ret = -1;
- if (!value || !size)
+ if (!value || !size || !xattr)
goto out;
+ ret = dict_keys_join (NULL, 0, xattr, NULL);
+
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;
}