summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2017-10-13 11:46:38 +0530
committerAmar Tumballi <amarts@redhat.com>2017-10-18 13:55:24 +0000
commite848410ab6d13871be6b57101788ea5183efe75c (patch)
tree97a1e95928c99a2e45ae4a6ccf743c7fe4b20068
parent614904fa7a31bf6f69074238b7e710a20e05e1bb (diff)
stack.h: make sure 'oldgroups' is never null
If 'oldgroups' is null, it can lead to a crash. Change-Id: I7a4f71256b07dc0ca3b988cad3694c21b150c99e BUG: 789278 Signed-off-by: Amar Tumballi <amarts@redhat.com>
-rw-r--r--libglusterfs/src/stack.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index ddad46c9673..856a9a4786e 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -428,13 +428,24 @@ copy_frame (call_frame_t *frame)
newstack->uid = oldstack->uid;
newstack->gid = oldstack->gid;
newstack->pid = oldstack->pid;
- newstack->ngrps = oldstack->ngrps;
newstack->op = oldstack->op;
newstack->type = oldstack->type;
if (call_stack_alloc_groups (newstack, oldstack->ngrps) != 0) {
mem_put (newstack);
return NULL;
}
+ if (!oldstack->groups) {
+ gf_msg_debug ("stack", EINVAL, "groups is null (ngrps: %d)",
+ oldstack->ngrps);
+ /* Considering 'groups' is NULL, set ngrps to 0 */
+ oldstack->ngrps = 0;
+
+ if (oldstack->groups_large)
+ oldstack->groups = oldstack->groups_large;
+ else
+ oldstack->groups = oldstack->groups_small;
+ }
+ newstack->ngrps = oldstack->ngrps;
memcpy (newstack->groups, oldstack->groups,
sizeof (gid_t) * oldstack->ngrps);
newstack->unique = oldstack->unique;