From 267aba64677a61e58aa9b0e0124515ba00d5d735 Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Thu, 22 Apr 2021 12:02:07 -0400 Subject: [PATCH] addroute: inet_pton cannot accept slash notation. We must fixup the argument before calling. --- nshlib/nsh_routecmds.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nshlib/nsh_routecmds.c b/nshlib/nsh_routecmds.c index 4e0e8ba3b..7dbd2ef48 100644 --- a/nshlib/nsh_routecmds.c +++ b/nshlib/nsh_routecmds.c @@ -151,6 +151,7 @@ int cmd_addroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int shift; int sockfd; int ret; + FAR char *sptr; /* First, check if we are setting the default route */ @@ -236,6 +237,17 @@ int cmd_addroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) goto errout; } + /* We need to remove the slash notation before passing it to inet_pton */ + + if (shift > 0) + { + sptr = strchr(argv[1], '/'); + if (sptr != NULL) + { + *sptr = '\0'; + } + } + /* Convert the target IP address string into its binary form */ #ifdef CONFIG_NET_IPv4