summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakshi <sabansal@redhat.com>2015-04-15 13:28:24 +0530
committerJeff Darcy <jdarcy@redhat.com>2016-04-14 05:55:50 -0700
commitd5409aae63a7ac5e5b3ea6cfa16c6250a028291c (patch)
tree9da5485f7ef56dd7adca9d7dddf2cbcdf4827cb9
parent1c9c776352c60deeda51be66fda6d44bf06d3796 (diff)
libglusterfs: coverity fix
fix missing varargs cleanup CID 1124856: string overflow CID 1124656: NULL return CID 1124374: constant expression Change-Id: Iead530c599bdfef05a40c68b892215f4e4f02247 BUG: 789278 Signed-off-by: Sakshi Bansal <sabansal@redhat.com> Reviewed-on: http://review.gluster.org/9630 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
-rw-r--r--libglusterfs/src/common-utils.c2
-rw-r--r--libglusterfs/src/dict.c5
-rw-r--r--libglusterfs/src/logging.c9
-rw-r--r--libglusterfs/src/mem-pool.c1
-rw-r--r--libglusterfs/src/options.c16
-rw-r--r--libglusterfs/src/timer.c1
6 files changed, 25 insertions, 9 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index a1b67596c6e..ac8babcc8ad 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -1363,7 +1363,7 @@ gf_string2int64 (const char *str, int64_t *n)
if (rv != 0)
return rv;
- if ((l >= INT64_MIN) && (l <= INT64_MAX)) {
+ if (l <= INT64_MAX) {
*n = (int64_t) l;
return 0;
}
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index c314a903b91..25ddff0d8c4 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -2727,6 +2727,11 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill)
goto out;
}
value = get_new_data ();
+
+ if (!value) {
+ ret = -1;
+ goto out;
+ }
value->len = vallen;
value->data = memdup (buf, vallen);
value->is_static = 0;
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index c233aedc359..4408c5f674c 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -914,6 +914,8 @@ out:
FREE (str2);
+ va_end (ap);
+
return ret;
}
@@ -2269,6 +2271,7 @@ err:
FREE (str2);
out:
+ va_end (ap);
return (0);
}
@@ -2318,7 +2321,9 @@ out:
if (str2)
FREE (str2);
- return ret;
+ va_end (ap);
+
+ return ret;
}
int
@@ -2470,5 +2475,7 @@ out:
FREE (str2);
+ va_end (ap);
+
return ret;
}
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 1ed1aba6c2d..9a1320993d3 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -226,6 +226,7 @@ gf_vasprintf (char **string_ptr, const char *format, va_list arg)
rv = vsnprintf (str, size, format, arg_save);
*string_ptr = str;
+ va_end (arg_save);
return (rv);
}
diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c
index c8f2585ae2b..53bd779861c 100644
--- a/libglusterfs/src/options.c
+++ b/libglusterfs/src/options.c
@@ -248,19 +248,20 @@ void
set_error_str (char *errstr, size_t len, volume_option_t *opt, const char *key,
const char *value)
{
- int i = 0;
- char given_array[4096] = {0,};
+ int i = 0;
+ int ret = 0;
+
+ ret = snprintf (errstr, len, "option %s %s: '%s' is not valid "
+ "(possible options are ", key, value, value);
for (i = 0; (i < ZR_OPTION_MAX_ARRAY_SIZE) && opt->value[i];) {
- strcat (given_array, opt->value[i]);
+ ret += snprintf (errstr + ret, len - ret, "%s", opt->value[i]);
if (((++i) < ZR_OPTION_MAX_ARRAY_SIZE) &&
(opt->value[i]))
- strcat (given_array, ", ");
+ ret += snprintf (errstr + ret, len - ret, ", ");
else
- strcat (given_array, ".");
+ ret += snprintf (errstr + ret, len - ret, ".)");
}
- snprintf (errstr, len, "option %s %s: '%s' is not valid "
- "(possible options are %s)", key, value, value, given_array);
return;
}
@@ -332,6 +333,7 @@ xlator_option_validate_str (xlator_t *xl, const char *key, const char *value,
out:
if (ret) {
set_error_str (errstr, sizeof (errstr), opt, key, value);
+
gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
errstr);
if (op_errstr)
diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c
index acd34d8b2a8..a072985acce 100644
--- a/libglusterfs/src/timer.c
+++ b/libglusterfs/src/timer.c
@@ -230,6 +230,7 @@ gf_timer_registry_init (glusterfs_ctx_t *ctx)
ctx->timer = reg;
gf_thread_create (&reg->th, NULL, gf_timer_proc, ctx);
+
}
out:
return ctx->timer;