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.

This commit is contained in:
Gregory Nutt 2018-09-30 08:46:52 -06:00
parent 2d9a916be1
commit 386c29bbaf

View File

@ -91,15 +91,25 @@ int netlib_parsehttpurl(FAR const char *url, FAR uint16_t *port,
while (*src != '\0' && *src != '/' && *src != ' ' && *src != ':') while (*src != '\0' && *src != '/' && *src != ' ' && *src != ':')
{ {
/* Make sure that there is space for another character in the hostname. /* Make sure that there is space for another character in the
* (reserving space for the null terminator) * 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; ret = -E2BIG;
break;
} }
} }