From fdf33589594968e2e8fc2f4799bea248a014d691 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 1 Dec 2019 09:25:27 +0100 Subject: sgsnemu: Fix null-pointer format string argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modern gcc-9.2.1 actually fails like this with --enable-werror active: In file included from sgsnemu.c:52: In function ‘process_options’, inlined from ‘main’ at sgsnemu.c:1557:6: ../lib/syserr.h:31:3: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 31 | logp2(sub, pri, __FILE__, __LINE__, 0, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 | fmt "\n", ##args); \ | ~~~~~~~~~~~~~~~~~ sgsnemu.c:435:3: note: in expansion of macro ‘SYS_ERR’ 435 | SYS_ERR(DSGSN, LOGL_ERROR, 0, | ^~~~~~~ sgsnemu.c: In function ‘main’: sgsnemu.c:436:42: note: format string is defined here 436 | "Listening address must be specified: %s!", | ^~ It is correct: We are dereferencing args_info.listen_addr in a branch which explicitly checks if that is NULL beforehand :/ Change-Id: I417f447f821d396aa92049e0a791121240f1cf44 --- sgsnemu/sgsnemu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index 863ea51..7904c49 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -433,8 +433,7 @@ static int process_options(int argc, char **argv) } } else { SYS_ERR(DSGSN, LOGL_ERROR, 0, - "Listening address must be specified: %s!", - args_info.listen_arg); + "Listening address must be specified!"); return -1; } -- cgit v1.2.3