setregid01: Fix security warning for string formatting
PATCH 1/1 setregid01: Fix security warning for string formatting
GCC 8.2.0 complains with the following:
setregid01.c: In function 'run':
setregid01.c:47:3: error: format not a string literal and no format arguments [-Werror=format-security]
tst_res(TFAIL | TTERRNO, tc->msg);
^~~~~~~because there is no string formatting in the message. This can be seen with CFLAGS set to:
-Wformat -Wformat-security -Werror=format-security
as Yocto Project's Poky does, e.g.:
http://errors.yoctoproject.org/Errors/Details/230043/
--- testcases/kernel/syscalls/setregid/setregid01.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/setregid/setregid01.c +2 -2
@@ -44,9 +44,9 @@ static void run(unsigned int n)TEST (SETREGID (*tc->arg1, *tc->arg2));if (TST_RET ==-1 ) -tst_res (TFAIL |TTERRNO , tc->msg); +tst_res (TFAIL |TTERRNO ,"%s" , tc->msg);else -tst_res (TPASS , tc->msg); +tst_res (TPASS ,"%s" , tc->msg); }static void setup (void )
Signature · 1 line
2.17.1
PATCH 1/1 setregid01: Fix security warning for string formatting
Quoted 37 lines · Daniel Díaz
GCC 8.2.0 complains with the following:
setregid01.c: In function 'run':
setregid01.c:47:3: error: format not a string literal and no format arguments [-Werror=format-security]tst_res(TFAIL | TTERRNO, tc->msg); ^~~~~~~because there is no string formatting in the message. This can be seen with CFLAGS set to:
-Wformat -Wformat-security -Werror=format-security
as Yocto Project's Poky does, e.g.:
http://errors.yoctoproject.org/Errors/Details/230043/Signed-off-by Daniel Díaz <[email protected]>---
testcases/kernel/syscalls/setregid/setregid01.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)testcases/kernel/syscalls/setregid/setregid01.c +2
-2@@ -44,9 +44,9 @@ static void run(unsigned int n)TEST (SETREGID (*tc->arg1, *tc->arg2));if (TST_RET ==-1 ) -tst_res (TFAIL |TTERRNO , tc->msg); +tst_res (TFAIL |TTERRNO ,"%s" , tc->msg);else -tst_res (TPASS , tc->msg); +tst_res (TPASS ,"%s" , tc->msg); }static void setup (void )Signature · 1 line
2.17.1
LGTM!
PATCH 1/1 setregid01: Fix security warning for string formatting
In reply to Daniel DíazHi Daniel,
thanks for your patch, merged.
Maybe we should have -Wformat -Wformat-security -Werror=format-security as the default.
Kind regards,
Petr
PATCH 1/1 setregid01: Fix security warning for string formatting
Hi!
Quoted 2 lines
Maybe we should have -Wformat -Wformat-security -Werror=format-security as the default.
I'm all for it but we have to check if a compiler on oldest supported distro works fine with these flags, othewise we would have to add a configure check...
Signature · 2 lines
Cyril Hrubis [email protected]