Skip to content

Commit e3c938e

Browse files
Kartik_Burmeejdarcy
Kartik_Burmee
authored andcommitted
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 <[email protected]>
1 parent f6ab03d commit e3c938e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xlators/mgmt/glusterd/src/glusterd-utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3929,7 +3929,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count,
39293929
ret = dict_get_str (peer_data, key, &parent_volname);
39303930
if (!ret)
39313931
strncpy (new_volinfo->parent_volname, parent_volname,
3932-
sizeof(new_volinfo->parent_volname));
3932+
sizeof(new_volinfo->parent_volname)-1);
39333933

39343934
memset (key, 0, sizeof (key));
39353935
snprintf (key, sizeof (key), "%s%d.brick_count", prefix, count);

0 commit comments

Comments
 (0)