summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/stub
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2017-11-08 06:08:02 -0500
committerAmar Tumballi <amarts@redhat.com>2017-11-09 21:18:52 +0000
commit0fc1c562d8b8d09ec2b59bc525ec5635a21a4561 (patch)
tree539ce7122b452b731cd9f57f6229d56c2a7136b4 /xlators/features/bit-rot/src/stub
parent2899a4f125735636fe7cd8db73c0b8a13289df9b (diff)
features/bitrot: Fix coverity issues
1. br_update_scrub_finish_time: BUFFER_SIZE_WARNING 2. br_read_bad_object_dir : DEADCODE 3. bit-rot.c: init : RESOURCE_LEAK 4. br_stub_fsetxattr : STACK_USE 5. br_stub_setxattr : STACK_USE 6. bit-rot-stub.c: init : BUFFER_SIZE_WARNING Change-Id: Ie620f431bd7548fedae2152aa756ccdcd89ddf89 Signed-off-by: Kotresh HR <khiremat@redhat.com> BUG: 789278
Diffstat (limited to 'xlators/features/bit-rot/src/stub')
-rw-r--r--xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h1
-rw-r--r--xlators/features/bit-rot/src/stub/bit-rot-stub.c39
-rw-r--r--xlators/features/bit-rot/src/stub/bit-rot-stub.h1
3 files changed, 28 insertions, 13 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h
index a33577c..1652a3e 100644
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h
@@ -28,6 +28,7 @@ enum br_mem_types {
gf_br_stub_mt_br_scanner_freq_t,
gf_br_stub_mt_sigstub_t,
gf_br_mt_br_child_event_t,
+ gf_br_stub_mt_misc,
gf_br_stub_mt_end,
};
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
index 10a1d81..8571789 100644
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
@@ -139,7 +139,8 @@ init (xlator_t *this)
GF_OPTION_INIT ("bitrot", priv->do_versioning, bool, free_mempool);
GF_OPTION_INIT ("export", tmp, str, free_mempool);
- strncpy (priv->export, tmp, sizeof (priv->export));
+ strncpy (priv->export, tmp, PATH_MAX-1);
+ priv->export[PATH_MAX-1] = '\0';
(void) snprintf (priv->stub_basepath, sizeof (priv->stub_basepath),
"%s/%s", priv->export, BR_STUB_QUARANTINE_DIR);
@@ -1304,6 +1305,28 @@ br_stub_handle_internal_xattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
return 0;
}
+static void
+br_stub_dump_xattr (xlator_t *this, dict_t *dict, int *op_errno)
+{
+ char *format = "(%s:%s)";
+ char *dump = NULL;
+
+ dump = GF_CALLOC (1, BR_STUB_DUMP_STR_SIZE, gf_br_stub_mt_misc);
+ if (!dump) {
+ *op_errno = ENOMEM;
+ goto out;
+ }
+ dict_dump_to_str (dict, dump, BR_STUB_DUMP_STR_SIZE, format);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ BRS_MSG_SET_INTERNAL_XATTR, "fsetxattr called on "
+ "internal xattr %s", dump);
+ out:
+ if (dump) {
+ GF_FREE (dump);
+ }
+ return;
+}
+
int
br_stub_fsetxattr (call_frame_t *frame, xlator_t *this,
fd_t *fd, dict_t *dict, int flags, dict_t *xdata)
@@ -1314,18 +1337,13 @@ br_stub_fsetxattr (call_frame_t *frame, xlator_t *this,
br_stub_private_t *priv = NULL;
int32_t op_ret = -1;
int32_t op_errno = EINVAL;
- char *format = "(%s:%s)";
- char dump[64*1024] = {0,};
priv = this->private;
if ((frame->root->pid != GF_CLIENT_PID_BITD &&
frame->root->pid != GF_CLIENT_PID_SCRUB) &&
br_stub_internal_xattr (dict)) {
- dict_dump_to_str (dict, dump, sizeof(dump), format);
- gf_msg (this->name, GF_LOG_ERROR, 0,
- BRS_MSG_SET_INTERNAL_XATTR, "fsetxattr called on "
- "internal xattr %s", dump);
+ br_stub_dump_xattr (this, dict, &op_errno);
goto unwind;
}
@@ -1405,14 +1423,9 @@ br_stub_setxattr (call_frame_t *frame, xlator_t *this,
{
int32_t op_ret = -1;
int32_t op_errno = EINVAL;
- char dump[64*1024] = {0,};
- char *format = "(%s:%s)";
if (br_stub_internal_xattr (dict)) {
- dict_dump_to_str (dict, dump, sizeof(dump), format);
- gf_msg (this->name, GF_LOG_ERROR, 0,
- BRS_MSG_SET_INTERNAL_XATTR, "setxattr called on "
- "internal xattr %s", dump);
+ br_stub_dump_xattr (this, dict, &op_errno);
goto unwind;
}
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h
index d8c8b6b..27a84e32 100644
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h
@@ -24,6 +24,7 @@
#include "glusterfs3-xdr.h"
#define BAD_OBJECT_THREAD_STACK_SIZE ((size_t)(1024*1024))
+#define BR_STUB_DUMP_STR_SIZE 65536
#define BR_PATH_MAX_EXTRA (PATH_MAX+1024)
#define BR_PATH_MAX_PLUS (PATH_MAX+2048)