diff options
author | Kartik_Burmee <kburmee@redhat.com> | 2017-11-13 15:03:05 +0530 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-11-13 16:35:49 +0000 |
commit | e3c938e01f1f71cda54ad278c20f41caa1340adc (patch) | |
tree | 4f75ac8fddd8fe68f5c5d6780e0f615d0ef5601a /xlators/mgmt/glusterd | |
parent | f6ab03d27cf394f8429b4c77cef0602547f6fd67 (diff) |
glusterd: buffer_size_warning coverity fix
function: glusterd_import_volinfo
problem: Calling strncpy with a maximum size argument of 256 bytes on destination array "new_volinfo->parent_volname" of size 256 bytes might leave the destination string unterminated.
fix: The third argument of strncpy specifies the number of characters to be copied from the source string to the destination string. To make sure that the final string in destination is always null terminated, we copy 1 less character than the total capacity of the destination array and the last element of the array will be filled by '/0' automatically by the strncpy function.
html link of issue: https://download.gluster.org/pub/gluster/glusterfs/static-analysis/master/glusterfs-coverity/2017-11-10-0f524f07/html/1/39glusterd-utils.c.html#error
Change-Id: I76b0d10e6a932b0885531c9be3c4f4ce7239f3e1
BUG: 789278
Signed-off-by: Kartik_Burmee <kburmee@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index b79bdcb1edf..86b9c1143c3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -3929,7 +3929,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count, ret = dict_get_str (peer_data, key, &parent_volname); if (!ret) strncpy (new_volinfo->parent_volname, parent_volname, - sizeof(new_volinfo->parent_volname)); + sizeof(new_volinfo->parent_volname)-1); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick_count", prefix, count); |