[PATCH] mdadm: fixed mdadm compilation on gcc8

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

 



From: Krzysztof Smolinski <krzysztof.smolinski@xxxxxxxxx>

GCC8 make more strict checks of possible truncation during snprintf
calls than GCC7 which cause compilation errors. This patch
fixes compilation of mdadm on GCC8 compiler.

Signed-off-by: Krzysztof Smolinski <krzysztof.smolinski@xxxxxxxxx>
---
 sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysfs.c b/sysfs.c
index c3137818..2bf9793d 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -1019,7 +1019,7 @@ int sysfs_rules_apply_check(const struct mdinfo *sra,
 	/* Check whether parameter is regular file,
 	 * exists and is under specified directory.
 	 */
-	char fname[MAX_SYSFS_PATH_LEN];
+	char fname[PATH_MAX];
 	char dname[MAX_SYSFS_PATH_LEN];
 	char resolved_path[PATH_MAX];
 	char resolved_dir[PATH_MAX];
@@ -1028,7 +1028,7 @@ int sysfs_rules_apply_check(const struct mdinfo *sra,
 		return -1;
 
 	snprintf(dname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/", sra->sys_name);
-	snprintf(fname, MAX_SYSFS_PATH_LEN, "%s/%s", dname, ent->name);
+	snprintf(fname, PATH_MAX, "%s/%s", dname, ent->name);
 
 	if (realpath(fname, resolved_path) == NULL ||
 	    realpath(dname, resolved_dir) == NULL)
-- 
2.16.4




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux