From a2c562eb4046ce88c8c2f2d250b0079942e7f10a Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Tue, 21 Aug 2018 18:31:03 +0300 Subject: {mount-common|fusermount|mount_darwin|umountd}.c: strncpy()->sprintf(), reduce strlen()'s 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(). 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: I369209b36d8356c3fe00d32f8bf56e74cf9963db updates: bz#1193929 Signed-off-by: Yaniv Kaul --- contrib/macfuse/mount_darwin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib/macfuse/mount_darwin.c') diff --git a/contrib/macfuse/mount_darwin.c b/contrib/macfuse/mount_darwin.c index f4ecacad86a..21ed7e503a6 100644 --- a/contrib/macfuse/mount_darwin.c +++ b/contrib/macfuse/mount_darwin.c @@ -94,7 +94,7 @@ gf_fuse_mount (const char *mountpoint, char *fsname, char *mnt_param, } /* sysctlbyname() includes the trailing '\0' in version_len */ - version_len_desired = strlen("2.x.y") + 1; + version_len_desired = sizeof ("2.x.y"); if (version_len != version_len_desired) { gf_log ("glusterfs-fuse", GF_LOG_ERROR, -- cgit