Fix drbdsetup-8.4 build with -Werror=format-security
PATCH 1/1 Fix drbdsetup-8.4 build with -Werror=format-security
Building drbdsetup-8.4 with -Werror=format-security (enabled by default for Debian builds) currently fails with the following errors:
drbdsetup.c: In function ‘print_command_usage’:
drbdsetup.c:2311:6: error: format not a string literal and no format arguments [-Werror=format-security]
wrap_printf(4, "|resource" + first);
^
drbdsetup.c:2315:6: error: format not a string literal and no format arguments [-Werror=format-security]
wrap_printf(4, "|minor" + first);
^
drbdsetup.c:2319:6: error: format not a string literal and no format arguments [-Werror=format-security]
wrap_printf(4, "|all" + first);
^cc1: some warnings being treated as errors <builtin>: recipe for target 'drbdsetup.o' failed
Note that the way wrap_printf is called in this case is indeed safe, however we comply with gcc by adding a "%s" format string to these calls.
Signed-off-by Apollon Oikonomopoulos <[email protected]>
--- user/legacy-84/drbdsetup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
user/legacy-84/drbdsetup.c +3 -3
@@ -2308,15 +2308,15 @@ static void print_command_usage(struct drbd_cmd *cm, enum usage_type ut)wrap_printf (4 ," {" );if (ctx &CTX_RESOURCE ) { -wrap_printf (4 ,"|resource" + first); +wrap_printf (4 ,"%s" ,"|resource" + first); first = false; }if (ctx &CTX_MINOR ) { -wrap_printf (4 ,"|minor" + first); +wrap_printf (4 ,"%s" ,"|minor" + first); first = false; }if (ctx &CTX_ALL ) { -wrap_printf (4 ,"|all" + first); +wrap_printf (4 ,"%s" ,"|all" + first); first = false; }wrap_printf (4 ,"}" );
Signature · 1 line
2.0.0.rc2