Handle the snprintf calculations more gracefully in case snprintf truncates the string.
Signed-off-by: Eric Sesterhenn <[email protected]> --- net/netfilter/x_tables.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index c83a3b5e1c6c..327617acbf05 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -408,6 +408,8 @@ textify_hooks(char *buf, size_t size, unsigned int mask, uint8_t nfproto) if (!(mask & (1 << i))) continue; res = snprintf(p, size, "%s%s", np ? "/" : "", names[i]); + if (res >= size) + return buf; if (res > 0) { size -= res; p += res; -- Eric Sesterhenn (Principal Security Consultant) X41 D-SEC GmbH, Dennewartstr. 25-27, D-52068 Aachen T: +49 241 9809418-0, Fax: -9 Unternehmenssitz: Aachen, Amtsgericht Aachen: HRB19989 Geschäftsführer: Markus Vervier
signature.asc
Description: OpenPGP digital signature

