[Bugs] [Bug 1193929] GlusterFS can be improved

bugzilla at redhat.com bugzilla at redhat.com
Fri Sep 7 16:17:52 UTC 2018


https://bugzilla.redhat.com/show_bug.cgi?id=1193929



--- Comment #335 from Worker Ant <bugzilla-bot at gluster.org> ---
COMMIT: https://review.gluster.org/20931 committed in master by "Atin
Mukherjee" <amukherj at redhat.com> with a commit message- multiple xlators
(mgmt): strncpy()->sprintf(), reduce strlen()'s

xlators/mgmt/glusterd/src/glusterd-geo-rep.c
xlators/mgmt/glusterd/src/glusterd-handshake.c
xlators/mgmt/glusterd/src/glusterd-sm.c
xlators/mgmt/glusterd/src/glusterd-store.c
xlators/mgmt/glusterd/src/glusterd-utils.c
xlators/mgmt/glusterd/src/glusterd-volgen.c
xlators/mgmt/glusterd/src/glusterd-volume-ops.c
xlators/mgmt/glusterd/src/glusterd.c

strncpy may not be very efficient for short strings copied into
a large buffer: If the length of src is less than n,
strncpy() writes additional null bytes to dest to ensure
that a total of n bytes are written.

Instead, use snprintf(). Try to ensure output is not
truncated.

Also:
- save the result of strlen() and re-use it when possible.
- move from strlen to SLEN (sizeof() ) for const strings.

Compile-tested only!

Change-Id: Ib5d001857236f43e41c4a51b5f48e1a33110aaeb
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul at redhat.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.


More information about the Bugs mailing list