diff options
author | Xavi Hernandez <xhernandez@redhat.com> | 2018-07-06 20:23:35 +0200 |
---|---|---|
committer | Xavi Hernandez <xhernandez@redhat.com> | 2018-07-10 16:28:24 +0200 |
commit | 6dc5dfef819cad69d6d4b4c1c305efa74236ad84 (patch) | |
tree | 6b325caf478689d8113279191ca1916e5f5b32ea /xlators/mgmt/glusterd/src/glusterd-handshake.c | |
parent | 03f1f5bdc46076178f1afdf8e2a76c5b973fe11f (diff) |
Fix compile warnings
This patch fixes compile warnings that appear with newer compilers. The
solution applied is only to remove the warnings, but it doesn't always
solve the problem in the best way. It assumes that the problem will never
happen, as the previous code assumed.
Change-Id: I6e8470d6c2e2dbd3bd7d324b5fd2f92ffdc3d6ec
updates: bz#1193929
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handshake.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 84dd077af73..35b6bed409e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -196,6 +196,7 @@ build_volfile_path (char *volume_id, char *path, xlator_t *this = NULL; glusterd_volinfo_t *volinfo = NULL; glusterd_conf_t *priv = NULL; + int32_t len = 0; this = THIS; GF_ASSERT (this); @@ -321,13 +322,18 @@ build_volfile_path (char *volume_id, char *path, goto out; } - snprintf (path_prefix, sizeof (path_prefix), "%s/snaps/%s", - priv->workdir, volinfo->snapshot->snapname); - + len = snprintf (path_prefix, sizeof (path_prefix), + "%s/snaps/%s", priv->workdir, + volinfo->snapshot->snapname); volid_ptr = volname; /* this is to ensure that volname recvd from get_snap_volname_and_volinfo is free'd */ free_ptr = volname; + if ((len < 0) || (len >= sizeof(path_prefix))) { + ret = -1; + goto out; + } + goto gotvolinfo; } @@ -408,8 +414,12 @@ build_volfile_path (char *volume_id, char *path, volid_ptr = volume_id; } - snprintf (path_prefix, sizeof (path_prefix), "%s/vols", - priv->workdir); + len = snprintf (path_prefix, sizeof (path_prefix), "%s/vols", + priv->workdir); + if ((len < 0) || (len >= sizeof(path_prefix))) { + ret = -1; + goto out; + } ret = glusterd_volinfo_find (volid_ptr, &volinfo); |