21ab4e
From 397c4f032bb835f389662ac0ac99d408d3a915f3 Mon Sep 17 00:00:00 2001
21ab4e
From: "Kaleb S. KEITHLEY" <kkeithle@redhat.com>
21ab4e
Date: Wed, 22 Feb 2017 13:55:00 -0500
21ab4e
Subject: [PATCH 339/361] gfapi: OBS build fails in post build analysis
21ab4e
21ab4e
Originally gfapi: create statedump when glusterd requests it
21ab4e
21ab4e
When GlusterD sends the STATEDUMP procedure to the libgfapi client, the
21ab4e
client checks if it matches the PID that should take the statedump. If
21ab4e
so, it will do a statedump for the glfs_t that is connected to this mgmt
21ab4e
connection.
21ab4e
21ab4e
See https://bugzilla.redhat.com/show_bug.cgi?id=1169302#c25 for the
21ab4e
OpenSuSE Build System post build analysis error.
21ab4e
21ab4e
See Change-Id: I70d6a1f4f19d525377aebc8fa57f51e513b92d84
21ab4e
    https://review.gluster.org/#/c/16415/
21ab4e
21ab4e
mainline:
21ab4e
> BUG: 1169302
21ab4e
> Reviewed-on: https://review.gluster.org/16722
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Niels de Vos <ndevos@redhat.com>
21ab4e
(cherry picked from commit d65525d2cc2cc7215bada4b3baccda0f48ca7bd9)
21ab4e
21ab4e
BUG: 1378085
21ab4e
Change-Id: I7775f44ce13e20c831e8f1015816a28471d35bb4
21ab4e
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/101320
21ab4e
Tested-by: Milind Changire <mchangir@redhat.com>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 api/src/glfs.c | 9 +++++----
21ab4e
 1 file changed, 5 insertions(+), 4 deletions(-)
21ab4e
21ab4e
diff --git a/api/src/glfs.c b/api/src/glfs.c
21ab4e
index 5474922..62441c9 100644
21ab4e
--- a/api/src/glfs.c
21ab4e
+++ b/api/src/glfs.c
21ab4e
@@ -1426,6 +1426,8 @@ pub_glfs_sysrq (struct glfs *fs, char sysrq)
21ab4e
 {
21ab4e
         glusterfs_ctx_t  *ctx = NULL;
21ab4e
         int               ret = 0;
21ab4e
+        char              msg[1024] = {0,}; /* should not exceed 1024 chars */
21ab4e
+        size_t            rem = sizeof (msg);
21ab4e
 
21ab4e
         if (!fs || !fs->ctx) {
21ab4e
                 ret = -1;
21ab4e
@@ -1438,13 +1440,12 @@ pub_glfs_sysrq (struct glfs *fs, char sysrq)
21ab4e
         switch (sysrq) {
21ab4e
         case GLFS_SYSRQ_HELP:
21ab4e
         {
21ab4e
-                char msg[1024]; /* help text should not exceed 1024 chars */
21ab4e
                 struct glfs_sysrq_help *usage;
21ab4e
 
21ab4e
-                msg[0] = '\0';
21ab4e
                 for (usage = glfs_sysrq_help; usage->sysrq; usage++) {
21ab4e
-                        strncat (msg, usage->msg, 1024);
21ab4e
-                        strncat (msg, " ", 1024);
21ab4e
+                        strncat (msg, usage->msg, rem);
21ab4e
+                        rem -= strlen (usage->msg);
21ab4e
+                        strncat (msg, " ", rem--);
21ab4e
                 }
21ab4e
 
21ab4e
                 /* not really an 'error', but make sure it gets logged */
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e