summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Braun <michael-dev@fami-braun.de>2020-05-02 12:11:43 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2020-05-02 18:48:09 +0200
commite9985b227c38795a80937f430593ff0ca52b37c4 (patch)
treeb7bded1edcf3319fd43789825faec7328edfd84c /src
parente10356a4acd2dac08defcb5ce902bed1b86aab7d (diff)
main: fix get_optstring truncating output
Without this patch, get_optstring returns optstring = +hvVcf:insNSI:d:aejuy. After this patch, get_optstring returns optstring = +hvVcf:insNSI:d:aejuypTt This is due to optstring containing up to two chars per option, thus it was too short. Fixes: 906facf31d1d ("main: fix ASAN -fsanitize=address error in get_optstring()") Signed-off-by: Michael Braun <michael-dev@fami-braun.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index d213c601..d830c7a2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -118,7 +118,7 @@ static const struct nft_opt nft_options[] = {
static const char *get_optstring(void)
{
- static char optstring[NR_NFT_OPTIONS + 2];
+ static char optstring[2 * NR_NFT_OPTIONS + 2];
if (!optstring[0]) {
size_t i, j;
@@ -128,6 +128,8 @@ static const char *get_optstring(void)
j += snprintf(optstring + j, sizeof(optstring) - j, "%c%s",
nft_options[i].val,
nft_options[i].arg ? ":" : "");
+
+ assert(j < sizeof(optstring));
}
return optstring;
}