Re: [PATCH iptables-nft 3/3] extensions: remove trailing spaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 24, 2022 at 02:49:39PM +0100, Florian Westphal wrote:
> Previous patches cause minor test breakage, e.g:
> exp: nft 'add rule ip mangle INPUT iifname "iifname" tcp dport 80 ct state invalid,untracked  counter synproxy sack-perm timestamp wscale 7 mss 1460'
> res: nft 'add rule ip mangle INPUT iifname "iifname" tcp dport 80 ct state invalid,untracked  counter synproxy sack-perm timestamp wscale 7 mss 1460 '
> 
> So fix up the ->xlate callbacks of the affected modules to not print a
> tailing space character.

I am considering something like this:

| diff --git a/libxtables/xtables.c b/libxtables/xtables.c
| index 479dbae078156..367eefaba8e74 100644
| --- a/libxtables/xtables.c
| +++ b/libxtables/xtables.c
| @@ -2496,6 +2496,11 @@ static void __xt_xlate_add(struct xt_xlate *xl, enum xt_xlate_type type,
|         struct xt_xlate_buf *buf = &xl->buf[type];
|         int len;
|  
| +       if (buf->off && !isspace(buf->data[buf->off - 1])) {
| +               buf->data[buf->off] = ' ';
| +               buf->off++;
| +               buf->rem--;
| +       }
|         len = vsnprintf(buf->data + buf->off, buf->rem, fmt, ap);
|         if (len < 0 || len >= buf->rem)
|                 xtables_error(RESOURCE_PROBLEM, "OOM");

Maybe it needs an extra xt_xlate_add_nospc() but it should eliminate the
majority of the "whitespace here or there or not at all" fiddling all over the
code. WDYT?

Cheers, Phil



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux