lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <OSBPR01MB37842549BE2C2957005AFE498E510@OSBPR01MB3784.jpnprd01.prod.outlook.com>
Date:   Mon, 16 Dec 2019 04:01:03 +0000
From:   "mizuta.takeshi@...itsu.com" <mizuta.takeshi@...itsu.com>
To:     "'netdev@...r.kernel.org'" <netdev@...r.kernel.org>,
        "'davem@...emloft.net'" <davem@...emloft.net>
CC:     "mizuta.takeshi@...itsu.com" <mizuta.takeshi@...itsu.com>
Subject: [PATCH iproute2 v5 1/2] ip-xfrm: Fix getprotobynumber() result to be
 print for each call.

Running "ip xfrm state help" shows wrong protocol.

  $ ip xfrm state help
  <snip>
  UPSPEC := proto { { tcp | tcp | tcp | tcp } [ sport PORT ] [ dport PORT ] |
                  { icmp | icmp | icmp } [ type NUMBER ] [ code NUMBER ] |

In order to get the character string from the protocol number, getprotobynumber(3) is called.
However, since the address obtained by getprotobynumber(3) is static,
it is necessary to print a character string each time getprotobynumber(3) is called.

Signed-off-by: MIZUTA Takeshi <mizuta.takeshi@...itsu.com>
---
 ip/xfrm_state.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index b03ccc5..e947a58 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -107,20 +107,16 @@ static void usage(void)
                "EXTRA-FLAG := dont-encap-dscp\n"
                "SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC ]\n"
                "UPSPEC := proto { { ");
-       fprintf(stderr,
-               "%s | %s | %s | %s",
-               strxf_proto(IPPROTO_TCP),
-               strxf_proto(IPPROTO_UDP),
-               strxf_proto(IPPROTO_SCTP),
-               strxf_proto(IPPROTO_DCCP));
+       fprintf(stderr, "%s | ", strxf_proto(IPPROTO_TCP));
+       fprintf(stderr, "%s | ", strxf_proto(IPPROTO_UDP));
+       fprintf(stderr, "%s | ", strxf_proto(IPPROTO_SCTP));
+       fprintf(stderr, "%s", strxf_proto(IPPROTO_DCCP));
        fprintf(stderr,
                " } [ sport PORT ] [ dport PORT ] |\n"
                "                  { ");
-       fprintf(stderr,
-               "%s | %s | %s",
-               strxf_proto(IPPROTO_ICMP),
-               strxf_proto(IPPROTO_ICMPV6),
-               strxf_proto(IPPROTO_MH));
+       fprintf(stderr, "%s | ", strxf_proto(IPPROTO_ICMP));
+       fprintf(stderr, "%s | ", strxf_proto(IPPROTO_ICMPV6));
+       fprintf(stderr, "%s", strxf_proto(IPPROTO_MH));
        fprintf(stderr,
                " } [ type NUMBER ] [ code NUMBER ] |\n");
        fprintf(stderr,
--
2.24.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ