summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2022-10-01 00:17:50 +0200
committerPhil Sutter <phil@nwl.cc>2022-10-02 01:35:34 +0200
commit11e06cbb3a87739a3d958ba4c2f08fea7b100a68 (patch)
treed5825e37b75d390f21e854f3b55fe9825934e86d
parent262dff31a998ef8e2507bbfd9349d761769888da (diff)
extensions: libip6t_dst: Fix output for empty options
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>
-rw-r--r--extensions/libip6t_dst.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/extensions/libip6t_dst.c b/extensions/libip6t_dst.c
index bf0e3e43..baa010f5 100644
--- a/extensions/libip6t_dst.c
+++ b/extensions/libip6t_dst.c
@@ -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 = ',';
}
}