Blob Blame History Raw
From 397c4f032bb835f389662ac0ac99d408d3a915f3 Mon Sep 17 00:00:00 2001
From: "Kaleb S. KEITHLEY" <kkeithle@redhat.com>
Date: Wed, 22 Feb 2017 13:55:00 -0500
Subject: [PATCH 339/361] gfapi: OBS build fails in post build analysis

Originally gfapi: create statedump when glusterd requests it

When GlusterD sends the STATEDUMP procedure to the libgfapi client, the
client checks if it matches the PID that should take the statedump. If
so, it will do a statedump for the glfs_t that is connected to this mgmt
connection.

See https://bugzilla.redhat.com/show_bug.cgi?id=1169302#c25 for the
OpenSuSE Build System post build analysis error.

See Change-Id: I70d6a1f4f19d525377aebc8fa57f51e513b92d84
    https://review.gluster.org/#/c/16415/

mainline:
> BUG: 1169302
> Reviewed-on: https://review.gluster.org/16722
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Niels de Vos <ndevos@redhat.com>
(cherry picked from commit d65525d2cc2cc7215bada4b3baccda0f48ca7bd9)

BUG: 1378085
Change-Id: I7775f44ce13e20c831e8f1015816a28471d35bb4
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/101320
Tested-by: Milind Changire <mchangir@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 api/src/glfs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/api/src/glfs.c b/api/src/glfs.c
index 5474922..62441c9 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -1426,6 +1426,8 @@ 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;
@@ -1438,13 +1440,12 @@ pub_glfs_sysrq (struct glfs *fs, char sysrq)
         switch (sysrq) {
         case GLFS_SYSRQ_HELP:
         {
-                char msg[1024]; /* help text should not exceed 1024 chars */
                 struct glfs_sysrq_help *usage;
 
-                msg[0] = '\0';
                 for (usage = glfs_sysrq_help; usage->sysrq; usage++) {
-                        strncat (msg, usage->msg, 1024);
-                        strncat (msg, " ", 1024);
+                        strncat (msg, usage->msg, rem);
+                        rem -= strlen (usage->msg);
+                        strncat (msg, " ", rem--);
                 }
 
                 /* not really an 'error', but make sure it gets logged */
-- 
1.8.3.1