summaryrefslogtreecommitdiffstats
path: root/contrib/fuse-lib
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-08-21 18:31:03 +0300
committerAmar Tumballi <amarts@redhat.com>2018-08-24 16:26:36 +0000
commita2c562eb4046ce88c8c2f2d250b0079942e7f10a (patch)
tree64e6733e2407126f546c824c474027f1a0540f81 /contrib/fuse-lib
parent938849a417727c85f1925dde641b3c6c54c71275 (diff)
{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 <ykaul@redhat.com>
Diffstat (limited to 'contrib/fuse-lib')
-rw-r--r--contrib/fuse-lib/mount-common.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/contrib/fuse-lib/mount-common.c b/contrib/fuse-lib/mount-common.c
index 6380dd8678e..cffd4c01ed5 100644
--- a/contrib/fuse-lib/mount-common.c
+++ b/contrib/fuse-lib/mount-common.c
@@ -32,7 +32,7 @@ mtab_needs_update (const char *mnt)
struct stat stbuf;
/* If mtab is within new mount, don't touch it */
- if (strncmp (mnt, _PATH_MOUNTED, strlen (mnt)) == 0 &&
+ if (strncmp (mnt, _PATH_MOUNTED, sizeof (_PATH_MOUNTED) - 1) == 0 &&
_PATH_MOUNTED[strlen (mnt)] == '/')
return 0;