48 lines
2.5 KiB
Diff
48 lines
2.5 KiB
Diff
From 2f53d01f14661f7a663090582ac4f2a5414328b5 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
Date: Wed, 9 Aug 2023 12:19:21 +0200
|
|
Subject: [PATCH] Pass a format string to warn()
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Building with -Werror=format-security compiler flag raised an error:
|
|
|
|
gcc -Isrc/ -I/usr/lib64/perl5/CORE -fPIC -DHAVE_PL_INFIX_PLUGIN -I. -Ihax -c -D_REENTRANT -D_GNU_SOURCE -O2 '-flto=auto' -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang '-Werror=format-security' '-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3' -Wp,-D_GLIBCXX_ASSERTIONS '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' -fstack-protector-strong '-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1' -m64 '-mtune=generic' -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE '-D_FILE_OFFSET_BITS=64' -O2 '-flto=auto' -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall '-Werror=format-security' '-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3' -Wp,-D_GLIBCXX_ASSERTIONS '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' -fstack-protector-strong '-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1' -m64 '-mtune=generic' -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -o src/keyword.o src/keyword.c
|
|
[...]
|
|
src/keyword.c: In function 'parse_piece':
|
|
src/keyword.c:422:7: error: format not a string literal and no format arguments [-Werror=format-security]
|
|
422 | warn(piece->u.str);
|
|
| ^~~~
|
|
|
|
This is becaue warn() expects a format string as a first argument, see proto.h:
|
|
|
|
Perl_warn(pTHX_ const char *pat, ...)
|
|
__attribute__format__(__printf__,pTHX_1,pTHX_2);
|
|
|
|
This patch fixes it by formatting the unknown string with "%s".
|
|
|
|
CPAN RT#149346
|
|
|
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
---
|
|
src/keyword.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/src/keyword.c b/src/keyword.c
|
|
index 30d0900..07aae26 100644
|
|
--- a/src/keyword.c
|
|
+++ b/src/keyword.c
|
|
@@ -419,7 +419,7 @@ static void parse_piece(pTHX_ SV *argsv, size_t *argidx, const struct XSParseKey
|
|
int warnbit = piece->type >> 24;
|
|
if(warnbit && !ckWARN(warnbit))
|
|
return;
|
|
- warn(piece->u.str);
|
|
+ warn("%s", piece->u.str);
|
|
return;
|
|
}
|
|
|
|
--
|
|
2.41.0
|
|
|