From 386c29bbaf65b659f8af00c65c1f8645db19bb98 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 30 Sep 2018 08:46:52 -0600 Subject: [PATCH] netutils/netlib/netlib_parsehttpurl.c: Rethink last commit. I think it still needs to continue parsing to the end of the hostname string after the E2BIG error has occurred. --- netutils/netlib/netlib_parsehttpurl.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/netutils/netlib/netlib_parsehttpurl.c b/netutils/netlib/netlib_parsehttpurl.c index 18efc9f15..a163b5c03 100644 --- a/netutils/netlib/netlib_parsehttpurl.c +++ b/netutils/netlib/netlib_parsehttpurl.c @@ -91,15 +91,25 @@ int netlib_parsehttpurl(FAR const char *url, FAR uint16_t *port, while (*src != '\0' && *src != '/' && *src != ' ' && *src != ':') { - /* Make sure that there is space for another character in the hostname. - * (reserving space for the null terminator) + /* Make sure that there is space for another character in the + * hostname (reserving space for the null terminator). */ - *dest++ = *src++; - if (--bytesleft <= 1) + if (bytesleft > 1) { + /* Copy the byte */ + + *dest++ = *src++; + bytesleft--; + } + else + { + /* Note the error, but continue parsing until the end of the + * hostname + */ + + src++; ret = -E2BIG; - break; } }