summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd.h
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2018-07-20 14:27:57 +0530
committerAtin Mukherjee <amukherj@redhat.com>2018-08-14 15:35:21 +0000
commit1f3bfe7b5d437ae3ecd202e0e224a62dbc98b133 (patch)
tree4e02ac75518c8906dbe830d3339668a9f595df07 /xlators/mgmt/glusterd/src/glusterd.h
parentd339f87a6fadf7bc4d680a657ddc404247e14c47 (diff)
glusterd: fix gcc7 warnings
[sh]$ gcc --version gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5) Warnings were of the type below: xlators/mgmt/glusterd/src/glusterd-store.c:3285:33: warning: ‘/options’ directive output may be truncated writing 8 bytes into a region of size between 1 and 4096 [-Wformat-truncation=] snprintf (path, len, "%s/options", conf->workdir); ^~~~~~~~ xlators/mgmt/glusterd/src/glusterd-store.c:1280:39: warning: ‘/snaps/’ directive output may be truncated writing 7 bytes into a region of size between 1 and 4096 [-Wformat-truncation=] snprintf (snap_fpath, len, "%s/snaps/%s/%s", priv->workdir, ^~~~~~~ * Also changed some places where there was issues with key size * Made sure all the 'char buf[SOMESIZE] = {0,};' are changed to 'char buf[SOMESIZE] = "";` - In the files I changed * Also edited coding standard to reflect that. updates: bz#1193929 Change-Id: I04c652624ac63199cea2077e46b3a5def37c3689 Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd.h')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index c2a69c79419..49a1dc6dc08 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -141,6 +141,16 @@ struct glusterd_volgen {
dict_t *dict;
};
+/* Keeping all the paths required in glusterd would
+ cause many buffer overflow errors, as we append
+ more defined paths to the brick path, workdir etc etc.
+ It is better to keep limit on this as lesser value,
+ so we get an option to continue with all functionalities.
+ For example, snapname max would be appended on brick-path and
+ would be stored on workdir... all of these being PATH_MAX, is
+ not an ideal situation for success. */
+#define VALID_GLUSTERD_PATHMAX (PATH_MAX - (256 + 64))
+
typedef struct {
struct _volfile_ctx *volfile;
pthread_mutex_t mutex;
@@ -148,8 +158,8 @@ typedef struct {
gf_boolean_t verify_volfile_checksum;
gf_boolean_t trace;
uuid_t uuid;
- char workdir[PATH_MAX];
- char rundir[PATH_MAX];
+ char workdir[VALID_GLUSTERD_PATHMAX];
+ char rundir[VALID_GLUSTERD_PATHMAX];
rpcsvc_t *rpc;
glusterd_svc_t shd_svc;
glusterd_svc_t nfs_svc;
@@ -212,10 +222,10 @@ typedef enum gf_brick_status {
struct glusterd_brickinfo {
char hostname[1024];
- char path[PATH_MAX];
- char real_path[PATH_MAX];
- char device_path[PATH_MAX];
- char mount_dir[PATH_MAX];
+ char path[VALID_GLUSTERD_PATHMAX];
+ char real_path[VALID_GLUSTERD_PATHMAX];
+ char device_path[VALID_GLUSTERD_PATHMAX];
+ char mount_dir[VALID_GLUSTERD_PATHMAX];
char brick_id[1024];/*Client xlator name, AFR changelog name*/
char fstype [NAME_MAX]; /* Brick file-system type */
char mnt_opts [1024]; /* Brick mount options */