From: Victor Julien Date: Thu, 13 Jul 2017 07:06:39 +0000 (+0200) Subject: gcc7: fix format truncation warning X-Git-Tag: suricata-4.0.0-rc2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e72553ff8b5b205f2f15b7937e1e756219464e9;p=thirdparty%2Fsuricata.git gcc7: fix format truncation warning detect-rpc.c: In function ‘DetectRpcParse’: detect-rpc.c:225:50: error: ‘%s’ directive argument is null [-Werror=format-truncation=] SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",args[i]); ^ util-debug.h:239:77: note: in definition of macro ‘SCLogErr’ int _sc_log_ret = snprintf(_sc_log_msg, SC_LOG_MAX_LOG_MSG_LEN, __VA_ARGS__); \ ^~~~~~~~~~~ detect-rpc.c:225:17: note: in expansion of macro ‘SCLogError’ SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",args[i]); ^~~~~~~~~~ --- diff --git a/src/detect-rpc.c b/src/detect-rpc.c index d7e41f07e0..2cfa721f2b 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -192,7 +192,7 @@ static DetectRpcData *DetectRpcParse (const char *rpcstr) rd->procedure = 0; int i; - for (i = 0; i < (ret -1); i++) { + for (i = 0; i < (ret - 1); i++) { if (args[i]) { switch (i) { case 0: @@ -201,7 +201,7 @@ static DetectRpcData *DetectRpcParse (const char *rpcstr) goto error; } rd->flags |= DETECT_RPC_CHECK_PROGRAM; - break; + break; case 1: if (args[i][0] != '*') { if (ByteExtractStringUint32(&rd->program_version, 10, strlen(args[i]), args[i]) <= 0) { @@ -210,7 +210,7 @@ static DetectRpcData *DetectRpcParse (const char *rpcstr) } rd->flags |= DETECT_RPC_CHECK_VERSION; } - break; + break; case 2: if (args[i][0] != '*') { if (ByteExtractStringUint32(&rd->procedure, 10, strlen(args[i]), args[i]) <= 0) { @@ -220,11 +220,11 @@ static DetectRpcData *DetectRpcParse (const char *rpcstr) rd->flags |= DETECT_RPC_CHECK_PROCEDURE; } break; - } - } else { - SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",args[i]); - goto error; } + } else { + SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",rpcstr); + goto error; + } } for (i = 0; i < (ret -1); i++){ if (args[i] != NULL)