summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/glfs.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c
index bd59027236a..10af6c78e17 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -1477,7 +1477,6 @@ pub_glfs_sysrq (struct glfs *fs, char sysrq)
glusterfs_ctx_t *ctx = NULL;
int ret = 0;
char msg[1024] = {0,}; /* should not exceed 1024 chars */
- size_t rem = sizeof (msg);
if (!fs || !fs->ctx) {
ret = -1;
@@ -1490,12 +1489,13 @@ pub_glfs_sysrq (struct glfs *fs, char sysrq)
switch (sysrq) {
case GLFS_SYSRQ_HELP:
{
- struct glfs_sysrq_help *usage;
+ struct glfs_sysrq_help *usage = NULL;
for (usage = glfs_sysrq_help; usage->sysrq; usage++) {
- strncat (msg, usage->msg, rem);
- rem -= strlen (usage->msg);
- strncat (msg, " ", rem--);
+ snprintf (msg + strlen (msg), /* append to msg */
+ sizeof (msg) - strlen (msg) - 2,
+ /* - 2 for the " " + terminating \0 */
+ " %s", usage->msg);
}
/* not really an 'error', but make sure it gets logged */