[dm-devel] [PATCH v3 87/87] libmultipath: fix a -Wformat-truncation warning from gcc 10

mwilck at suse.com mwilck at suse.com
Wed Aug 19 13:18:19 UTC 2020


From: Martin Wilck <mwilck at suse.com>

This fixes a warning seen with gcc 10 on x86 (32 bit).
Fix it by checking the snprintf() return value.

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 libmultipath/util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libmultipath/util.c b/libmultipath/util.c
index 207e63c..1512424 100644
--- a/libmultipath/util.c
+++ b/libmultipath/util.c
@@ -250,9 +250,9 @@ int systemd_service_enabled_in(const char *dev, const char *prefix)
 		p = d->d_name + strlen(d->d_name) - 6;
 		if (strcmp(p, ".wants"))
 			continue;
-		snprintf(file, sizeof(file), "%s/%s/%s",
-			 path, d->d_name, service);
-		if (stat(file, &stbuf) == 0) {
+		if (!safe_sprintf(file, "%s/%s/%s",
+				  path, d->d_name, service)
+		    && stat(file, &stbuf) == 0) {
 			condlog(3, "%s: found %s", dev, file);
 			found++;
 			break;
-- 
2.28.0





More information about the dm-devel mailing list