addroute: inet_pton cannot accept slash notation. We must fixup the argument before calling.

This commit is contained in:
Anthony Merlino 2021-04-22 12:02:07 -04:00 committed by Xiang Xiao
parent 80eba3aad1
commit 267aba6467

View File

@ -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