* [PATCH] main: fix get_optstring truncating output
@ 2020-05-02 10:11 Michael Braun
2020-05-02 16:49 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Michael Braun @ 2020-05-02 10:11 UTC (permalink / raw)
To: netfilter-devel; +Cc: Michael Braun
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.
Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
---
src/main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] main: fix get_optstring truncating output
2020-05-02 10:11 [PATCH] main: fix get_optstring truncating output Michael Braun
@ 2020-05-02 16:49 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2020-05-02 16:49 UTC (permalink / raw)
To: Michael Braun; +Cc: netfilter-devel
On Sat, May 02, 2020 at 12:11:43PM +0200, Michael Braun wrote:
> 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.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-02 16:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 10:11 [PATCH] main: fix get_optstring truncating output Michael Braun
2020-05-02 16:49 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).