From 2f15ffd6b5beef9abd501c594bc3cb38c2683f77 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 2 Jul 2010 04:55:28 +0000 Subject: NULL dereference fixes in code base after running with 'clang' * 212 logical (NULL deref/divide by zero) errors reduced to 28 (27 of them in contrib/ and lex part of codebase, 1 is invalid) * 11 API errors reduced to 0 Signed-off-by: Amar Tumballi Signed-off-by: Anand V. Avati BUG: 966 (NULL check for avoiding NULL dereferencing of pointers..) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=966 --- xlators/storage/posix/src/posix.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'xlators/storage') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index e9a8fc88692..2aba365e62b 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -530,7 +530,7 @@ out: dict_ref (xattr); STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, - loc->inode, &buf, xattr, &postparent); + (loc)?loc->inode:NULL, &buf, xattr, &postparent); if (xattr) dict_unref (xattr); @@ -1175,7 +1175,7 @@ posix_mknod (call_frame_t *frame, xlator_t *this, SET_TO_OLD_FS_ID (); STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno, - loc->inode, &stbuf, &preparent, &postparent); + (loc)?loc->inode:NULL, &stbuf, &preparent, &postparent); if ((op_ret == -1) && (!was_present)) { unlink (real_path); @@ -1430,7 +1430,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, SET_TO_OLD_FS_ID (); STACK_UNWIND_STRICT (mkdir, frame, op_ret, op_errno, - loc->inode, &stbuf, &preparent, &postparent); + (loc)?loc->inode:NULL, &stbuf, &preparent, &postparent); if ((op_ret == -1) && (!was_present)) { unlink (real_path); @@ -1702,7 +1702,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this, SET_TO_OLD_FS_ID (); STACK_UNWIND_STRICT (symlink, frame, op_ret, op_errno, - loc->inode, &stbuf, &preparent, &postparent); + (loc)?loc->inode:NULL, &stbuf, &preparent, &postparent); if ((op_ret == -1) && (!was_present)) { unlink (real_path); @@ -1925,7 +1925,8 @@ posix_link (call_frame_t *frame, xlator_t *this, SET_TO_OLD_FS_ID (); STACK_UNWIND_STRICT (link, frame, op_ret, op_errno, - oldloc->inode, &stbuf, &preparent, &postparent); + (oldloc)?oldloc->inode:NULL, &stbuf, &preparent, + &postparent); if ((op_ret == -1) && (!was_present)) { unlink (real_newpath); @@ -2145,7 +2146,8 @@ posix_create (call_frame_t *frame, xlator_t *this, } STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, - fd, loc->inode, &stbuf, &preparent, &postparent); + fd, (loc)?loc->inode:NULL, &stbuf, &preparent, + &postparent); return 0; } @@ -3543,11 +3545,11 @@ do_xattrop (call_frame_t *frame, xlator_t *this, if (loc) { path = gf_strdup (loc->path); inode = loc->inode; - } else { + } else if (fd) { inode = fd->inode; } - while (trav) { + while (trav && inode) { count = trav->value->len / sizeof (int32_t); array = GF_CALLOC (count, sizeof (int32_t), gf_posix_mt_int32_t); -- cgit