From b68c27ea74d5295ea3eac4f066f3fdf86a79399a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Sun, 8 Mar 2020 09:29:04 +0100 Subject: [PATCH] Silenced warnings about string lengths in snprintf() Adjust string lengths to the worst case estimated by the compiler, even though they cannot be reached. --- libntfs-3g/ioctl.c | 3 ++- libntfs-3g/realpath.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libntfs-3g/ioctl.c b/libntfs-3g/ioctl.c index 6c49395d..66cedaf9 100644 --- a/libntfs-3g/ioctl.c +++ b/libntfs-3g/ioctl.c @@ -141,7 +141,8 @@ static int fstrim_limits(ntfs_volume *vol, u64 *discard_max_bytes) { struct stat statbuf; - char path1[80], path2[80]; + char path1[40]; /* holds "/sys/dev/block/%d:%d" */ + char path2[40 + sizeof(path1)]; /* less than 40 bytes more than path1 */ int ret; /* Stat the backing device. Caller has ensured it is a block device. */ diff --git a/libntfs-3g/realpath.c b/libntfs-3g/realpath.c index a93bc698..d56667e4 100644 --- a/libntfs-3g/realpath.c +++ b/libntfs-3g/realpath.c @@ -45,8 +45,8 @@ canonicalize_dm_name(const char *ptname, char *canonical) { FILE *f; size_t sz; - char path[MAPPERNAMELTH + 24]; char name[MAPPERNAMELTH + 16]; + char path[sizeof(name) + 16]; char *res = NULL; snprintf(path, sizeof(path), "/sys/block/%s/dm/name", ptname);