summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanju Rakonde <srakonde@redhat.com>2018-08-29 00:18:32 +0530
committerAtin Mukherjee <amukherj@redhat.com>2018-09-04 14:01:59 +0000
commit8612a1ca192333c2b760455661647d83bed2fd92 (patch)
tree238fbeab56fbfff4182583d89c9829197ba28876
parent13298d2b3893edb5d147ea3bcb9902ee5be4b3ad (diff)
glusterd: Fix Buffer size issues
This patch fixes buffer size issue 1138522. Change-Id: Ia12fc8f34f75704f8ed3efae2022c4fd67a8c76c updates: bz#789278 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
-rw-r--r--rpc/rpc-lib/src/protocol-common.h8
-rw-r--r--xlators/cluster/afr/src/afr-common.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h15
3 files changed, 16 insertions, 13 deletions
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index c26cb6966c7..1dfd6d5128b 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -277,7 +277,7 @@ typedef enum {
struct gf_gsync_detailed_status_ {
char node[NAME_MAX];
char master[NAME_MAX];
- char brick[NAME_MAX];
+ char brick[PATH_MAX];
char slave_user[NAME_MAX];
char slave[NAME_MAX];
char slave_node[NAME_MAX];
@@ -369,9 +369,9 @@ typedef enum gf_getspec_flags_type gf_getspec_flags_type;
#define GD_MGMT_HNDSK_PROGRAM 1239873 /* Completely random */
#define GD_MGMT_HNDSK_VERSION 1
-#define GD_VOLUME_NAME_MAX 256 /* Maximum size of volume name */
-#define GD_VOLUME_NAME_MAX_TIER (GD_VOLUME_NAME_MAX + 5) /*+5 needed for '-hot
- and '-cold' suffixes*/
+#define GD_VOLUME_NAME_MAX ((NAME_MAX + 1) - 5) /* Maximum size of volume name */
+#define GD_VOLUME_NAME_MAX_TIER (GD_VOLUME_NAME_MAX + 5) /* +5 needed for '-hot'
+ and '-cold' suffixes*/
#define GLUSTER_PROCESS_UUID_FMT "CTX_ID:%s-GRAPH_ID:%d-PID:%d-HOST:%s-PC_NAME:%s-RECON_NO:%s"
#endif /* !_PROTOCOL_COMMON_H */
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 0b1d4628c4e..702973a6ef4 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -6403,11 +6403,11 @@ afr_get_split_brain_status (void *opaque)
/* Calculation for string length :
* (child_count X length of child-name) + strlen (" Choices :")
* child-name consists of :
- * a) 256 = max characters for volname according to GD_VOLUME_NAME_MAX
+ * a) 251 = max characters for volname according to GD_VOLUME_NAME_MAX
* b) strlen ("-client-00,") assuming 16 replicas
*/
- choices = alloca0 (priv->child_count * (256 + strlen ("-client-00,")) +
- strlen (" Choices:"));
+ choices = alloca0 (priv->child_count * (251 + sizeof("-client-00,")) +
+ sizeof(" Choices:"));
ret = afr_is_split_brain (frame, this, inode, loc->gfid, &d_spb,
&m_spb);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index e0864c04148..71ac45cd241 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -221,7 +221,7 @@ typedef enum gf_brick_status {
} gf_brick_status_t;
struct glusterd_brickinfo {
- char hostname[1024];
+ char hostname[NAME_MAX];
char path[VALID_GLUSTERD_PATHMAX];
char real_path[VALID_GLUSTERD_PATHMAX];
char device_path[VALID_GLUSTERD_PATHMAX];
@@ -407,12 +407,15 @@ struct glusterd_volinfo_ {
the volume which is snapped. In
case of a non-snap volume, this
field will be initialized as N/A */
- char volname[GD_VOLUME_NAME_MAX + 5];
- /* An extra 5 bytes are allocated.
- * Reason is, As part of the tiering
+ char volname[NAME_MAX + 1];
+ /* NAME_MAX + 1 will be equal to
+ * GD_VOLUME_NAME_MAX + 5.(also to
+ * GD_VOLUME_NAME_MAX_TIER). An extra 5
+ * bytes are added to GD_VOLUME_NAME_MAX
+ * because, as part of the tiering
* volfile generation code, we are
- * temporarily appending either hot
- * or cold */
+ * temporarily appending either "-hot"
+ * or "-cold" */
int type;
int brick_count;
uint64_t snap_count;