From: Tuomas Tynkkynen Date: Tue, 29 Aug 2017 13:37:14 +0000 (+0300) Subject: fsx: Fix -Wformat-security warnings X-Git-Tag: v2022.05.01~1901 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8d085f7a03d472caafd8f82172bee2bdaacd6a73;p=xfstests-dev.git fsx: Fix -Wformat-security warnings 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 Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/ltp/fsx.c b/ltp/fsx.c index 15029056..cc0a8978 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -211,9 +211,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