summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-07-02 04:55:28 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-02 05:17:03 -0700
commit2f15ffd6b5beef9abd501c594bc3cb38c2683f77 (patch)
tree107176560e1a97c42f3535380ef49d4dee3b0cd6 /xlators/storage/posix
parent3dc79ca8e6119f5ff61058cc87f9a4fc251017ef (diff)
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 <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 966 (NULL check for avoiding NULL dereferencing of pointers..) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=966
Diffstat (limited to 'xlators/storage/posix')
-rw-r--r--xlators/storage/posix/src/posix.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index e9a8fc886..2aba365e6 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);