summaryrefslogtreecommitdiffstats
path: root/xlators/features/trash
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/features/trash
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/features/trash')
-rw-r--r--xlators/features/trash/src/trash.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c
index c51d55a..d60bf4b 100644
--- a/xlators/features/trash/src/trash.c
+++ b/xlators/features/trash/src/trash.c
@@ -96,7 +96,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
- gf_log (this->name, GF_LOG_DEBUG, "out of memory");
+ gf_log (this->name, GF_LOG_ERROR, "out of memory");
+ goto out;
}
loop_count = local->loop_count;
@@ -113,7 +114,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
tmp_path = memdup (local->newpath, count);
if (!tmp_path) {
- gf_log (this->name, GF_LOG_DEBUG, "out of memory");
+ gf_log (this->name, GF_LOG_ERROR, "out of memory");
+ goto out;
}
tmp_loc.path = tmp_path;
@@ -156,7 +158,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
tmp_path = memdup (local->newpath, count);
if (!tmp_path) {
- gf_log (this->name, GF_LOG_DEBUG, "out of memory");
+ gf_log (this->name, GF_LOG_ERROR, "out of memory");
+ goto out;
}
tmp_loc.path = tmp_path;
@@ -167,7 +170,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
out:
GF_FREE (cookie);
- GF_FREE (tmp_str);
+ if (tmp_str)
+ GF_FREE (tmp_str);
return 0;
}
@@ -399,6 +403,7 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
+ goto out;
}
if ((op_ret == -1) && (op_errno == ENOENT)) {
@@ -439,7 +444,8 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
out:
GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
- GF_FREE (tmp_str);
+ if (tmp_str)
+ GF_FREE (tmp_str);
return 0;
}
@@ -848,13 +854,14 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
if (!local)
- return 0;
+ goto out;
loop_count = local->loop_count;
tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
+ goto out;
}
if ((op_ret == -1) && (op_errno == ENOENT)) {
@@ -902,6 +909,7 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
loop_count = ++local->loop_count;
}
UNLOCK (&frame->lock);
+
tmp_dirname = strchr (tmp_str, '/');
while (tmp_dirname) {
count = tmp_dirname - tmp_str;
@@ -926,7 +934,8 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
out:
GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
- GF_FREE (tmp_str);
+ if (tmp_str)
+ GF_FREE (tmp_str);
return 0;
}
@@ -1213,13 +1222,14 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
if (!local)
- return 0;
+ goto out;
loop_count = local->loop_count;
tmp_str = gf_strdup (local->newpath);
if (!tmp_str) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
+ goto out;
}
if ((op_ret == -1) && (op_errno == ENOENT)) {
@@ -1292,7 +1302,8 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
out:
GF_FREE (cookie); /* strdup (dir_name) was sent here :) */
- GF_FREE (tmp_str);
+ if (tmp_str)
+ GF_FREE (tmp_str);
return 0;
}
@@ -1484,6 +1495,7 @@ init (xlator_t *this)
gf_trash_mt_trash_elim_pattern_t);
if (!trav) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
+ break;
}
trav->pattern = component;
trav->next = _priv->eliminate;