|
|
f5dd7b |
From fd5b09c9a9107f0393ce194c4aac6e7b8f163e85 Mon Sep 17 00:00:00 2001
|
|
|
f5dd7b |
From: Krzysztof Smolinski <krzysztof.smolinski@intel.com>
|
|
|
f5dd7b |
Date: Fri, 16 Aug 2019 11:06:17 +0200
|
|
|
f5dd7b |
Subject: [RHEL7.8 PATCH V2 35/47] mdadm: check value returned by snprintf
|
|
|
f5dd7b |
against errors
|
|
|
f5dd7b |
|
|
|
f5dd7b |
GCC 8 checks possible truncation during snprintf more strictly
|
|
|
f5dd7b |
than GCC 7 which result in compilation errors. To fix this
|
|
|
f5dd7b |
problem checking result of snprintf against errors has been added.
|
|
|
f5dd7b |
|
|
|
f5dd7b |
Signed-off-by: Krzysztof Smolinski <krzysztof.smolinski@intel.com>
|
|
|
f5dd7b |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
f5dd7b |
---
|
|
|
f5dd7b |
sysfs.c | 12 ++++++++++--
|
|
|
f5dd7b |
1 file changed, 10 insertions(+), 2 deletions(-)
|
|
|
f5dd7b |
|
|
|
f5dd7b |
diff --git a/sysfs.c b/sysfs.c
|
|
|
f5dd7b |
index c313781..2995713 100644
|
|
|
f5dd7b |
--- a/sysfs.c
|
|
|
f5dd7b |
+++ b/sysfs.c
|
|
|
f5dd7b |
@@ -1023,12 +1023,20 @@ int sysfs_rules_apply_check(const struct mdinfo *sra,
|
|
|
f5dd7b |
char dname[MAX_SYSFS_PATH_LEN];
|
|
|
f5dd7b |
char resolved_path[PATH_MAX];
|
|
|
f5dd7b |
char resolved_dir[PATH_MAX];
|
|
|
f5dd7b |
+ int result;
|
|
|
f5dd7b |
|
|
|
f5dd7b |
if (sra == NULL || ent == NULL)
|
|
|
f5dd7b |
return -1;
|
|
|
f5dd7b |
|
|
|
f5dd7b |
- snprintf(dname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/", sra->sys_name);
|
|
|
f5dd7b |
- snprintf(fname, MAX_SYSFS_PATH_LEN, "%s/%s", dname, ent->name);
|
|
|
f5dd7b |
+ result = snprintf(dname, MAX_SYSFS_PATH_LEN,
|
|
|
f5dd7b |
+ "/sys/block/%s/md/", sra->sys_name);
|
|
|
f5dd7b |
+ if (result < 0 || result >= MAX_SYSFS_PATH_LEN)
|
|
|
f5dd7b |
+ return -1;
|
|
|
f5dd7b |
+
|
|
|
f5dd7b |
+ result = snprintf(fname, MAX_SYSFS_PATH_LEN,
|
|
|
f5dd7b |
+ "%s/%s", dname, ent->name);
|
|
|
f5dd7b |
+ if (result < 0 || result >= MAX_SYSFS_PATH_LEN)
|
|
|
f5dd7b |
+ return -1;
|
|
|
f5dd7b |
|
|
|
f5dd7b |
if (realpath(fname, resolved_path) == NULL ||
|
|
|
f5dd7b |
realpath(dname, resolved_dir) == NULL)
|
|
|
f5dd7b |
--
|
|
|
f5dd7b |
2.7.5
|
|
|
f5dd7b |
|