Skip to contentSkip to conversation

pidfd_send_signal03: fix compile error with -Werror=format-security flag

PATCH New Yi Zhao 2 participants 2 messages Dec 5, 2019

lore
Share & tools
lore

Yi Zhao

author
#0 lore raw

PATCH 1/1 pidfd_send_signal03: fix compile error with -Werror=format-security flag

Fixed when compile with "-Wformat -Wformat-security -Werror=format-security":

In file included from ../../../../include/tst_test.h:85,

                 from pidfd_send_signal.h:10,
                 from pidfd_send_signal03.c:21:

pidfd_send_signal03.c: In function 'verify_pidfd_send_signal':
../../../../include/tst_safe_file_ops.h:53:27: error: format not a string literal and no format arguments [-Werror=format-security]
53 | (path), (fmt), ## __VA_ARGS__)
| ^~~~~
pidfd_send_signal03.c:62:3: note: in expansion of macro 'SAFE_FILE_PRINTF'

   62 |   SAFE_FILE_PRINTF(last_pid_file, pid_str);
      |   ^~~~~~~~~~~~~~~~
---
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal03.c     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal03.c +1 -1
index 27dbc6626..19d943d06 100644
@@ -59,7 +59,7 @@ static void verify_pidfd_send_signal(void)
 
 		/* Manipulate PID for next process */
 		sprintf(pid_str, "%d", pid - 1);
-		SAFE_FILE_PRINTF(last_pid_file, pid_str);
+		SAFE_FILE_PRINTF(last_pid_file, "%s", pid_str);
 
 		new_pid = SAFE_FORK();
 		if (new_pid == 0) {
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 pidfd_send_signal03: fix compile error with -Werror=format-security flag

Pushed. Thanks for the fix.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191205/2f9e6384/attachment.htm>