[PATCH 4/4] lib/sysfs: fix format overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



lib/sysfs.c:343:31: warning: '/start' directive output may be truncated
writing 6 bytes into a region of size between 1 and 256
[-Wformat-truncation=]

lib/sysfs.c:372:32: warning: '/partition' directive output may be truncated
writing 10 bytes into a region of size between 1 and 256
[-Wformat-truncation=]

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 lib/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/sysfs.c b/lib/sysfs.c
index cc290faac..6272b80b4 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -307,7 +307,7 @@ static struct dirent *xreaddir(DIR *dp)
 
 int sysfs_is_partition_dirent(DIR *dir, struct dirent *d, const char *parent_name)
 {
-	char path[256];
+	char path[strlen(d->d_name) + sizeof("/start") + 1];
 
 #ifdef _DIRENT_HAVE_D_TYPE
 	if (d->d_type != DT_DIR &&
@@ -356,7 +356,6 @@ dev_t sysfs_partno_to_devno(struct sysfs_cxt *cxt, int partno)
 {
 	DIR *dir;
 	struct dirent *d;
-	char path[256];
 	dev_t devno = 0;
 
 	dir = sysfs_opendir(cxt, NULL);
@@ -365,6 +364,7 @@ dev_t sysfs_partno_to_devno(struct sysfs_cxt *cxt, int partno)
 
 	while ((d = xreaddir(dir))) {
 		int n, maj, min;
+		char path[strlen(d->d_name) + sizeof("/partition") + 1];
 
 		if (!sysfs_is_partition_dirent(dir, d, NULL))
 			continue;
-- 
2.13.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux