From fd22b6372255e642617d9d95275df240e8d31fea Mon Sep 17 00:00:00 2001 From: mlondono74 <43219046+mlondono74@users.noreply.github.com> Date: Thu, 17 Nov 2022 15:34:08 -0500 Subject: [PATCH] fix issue with reading ipv6 routes. Handle space ahead of first line of route. --- netutils/netlib/netlib_ipv6route.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/netutils/netlib/netlib_ipv6route.c b/netutils/netlib/netlib_ipv6route.c index 59858b661..c35e26f4a 100644 --- a/netutils/netlib/netlib_ipv6route.c +++ b/netutils/netlib/netlib_ipv6route.c @@ -28,7 +28,7 @@ #include #include #include - +#include #include #include "netutils/netlib.h" @@ -110,6 +110,7 @@ ssize_t netlib_read_ipv6route(FILE *stream, char line[PROCFS_LINELEN]; FAR char *addr; int ret; + int idx = 0; DEBUGASSERT(stream != NULL && route != NULL); @@ -131,9 +132,14 @@ ssize_t netlib_read_ipv6route(FILE *stream, return 0; } - /* The first line of the group should consist of a number index */ + /* First non-space char of 1st line should be a number index */ - if (line[0] < '0' || line[0] > 9) + while (isspace(line[idx])) + { + idx++; + } + + if (line[idx] < '0' || line[idx] > '9') { return -EINVAL; }