diff mbox series

[iptables,2/3] extensions: libip6t_dst: Fix output for empty options

Message ID 20221001233906.5386-2-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series [iptables,1/3] extensions: libebt_stp: Eliminate duplicate space in output | expand

Commit Message

Phil Sutter Oct. 1, 2022, 11:39 p.m. UTC
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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/extensions/libip6t_dst.c b/extensions/libip6t_dst.c
index bf0e3e436665d..baa010f56ac22 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 = ',';
 	}
 }