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

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

 



From: Martin Wilck <mwilck@xxxxxxxx>

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@xxxxxxxx>
---
 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


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux