[PATCH 2/3] fsx: Fix -Wformat-security warnings

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



Some distros (NixOS) have their build environment enable
-Werror=format-security by default for security/hardening reasons.
Currently fsx fails to build due to this:

fsx.c: In function 'prt':
fsx.c:215:18: error: format not a string literal and no format arguments [-Werror=format-security]
  fprintf(stdout, buffer);
                  ^
fsx.c:217:20: error: format not a string literal and no format arguments [-Werror=format-security]
   fprintf(fsxlogf, buffer);
                    ^
Indeed the compiler is correct here, if the message-to-be-printed were
to contain a '%', unpredictable things would happen. Fix this.

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@xxxxxx>
---
 ltp/fsx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ltp/fsx.c b/ltp/fsx.c
index 3713bbe3..fba2b4d8 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -212,9 +212,9 @@ prt(const char *fmt, ...)
 	va_start(args, fmt);
 	vsnprintf(buffer, BUF_SIZE, fmt, args);
 	va_end(args);
-	fprintf(stdout, buffer);
+	fprintf(stdout, "%s", buffer);
 	if (fsxlogf)
-		fprintf(fsxlogf, buffer);
+		fprintf(fsxlogf, "%s", buffer);
 }
 
 void
-- 
2.13.0

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



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux