]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
extensions: libip6t_dst: Fix output for empty options
authorPhil Sutter <phil@nwl.cc>
Fri, 30 Sep 2022 22:17:50 +0000 (00:17 +0200)
committerPhil Sutter <phil@nwl.cc>
Sat, 1 Oct 2022 23:35:34 +0000 (01:35 +0200)
If no --dst-opts were given, print_options() would print just a
whitespace.

Fixes: 73866357e4a7a ("iptables: do not print trailing whitespaces")
Signed-off-by: Phil Sutter <phil@nwl.cc>
extensions/libip6t_dst.c

index bf0e3e436665d2da02e3fa359f48f91360ebce69..baa010f56ac222dbcc57c801cf884b80cc4ad583 100644 (file)
@@ -125,15 +125,15 @@ static void
 print_options(unsigned int optsnr, uint16_t *optsp)
 {
        unsigned int i;
+       char sep = ' ';
 
-       printf(" ");
        for(i = 0; i < optsnr; i++) {
-               printf("%d", (optsp[i] & 0xFF00) >> 8);
+               printf("%c%d", sep, (optsp[i] & 0xFF00) >> 8);
 
                if ((optsp[i] & 0x00FF) != 0x00FF)
                        printf(":%d", (optsp[i] & 0x00FF));
 
-               printf("%c", (i != optsnr - 1) ? ',' : ' ');
+               sep = ',';
        }
 }