netlib_parsehttpurl: Fix pathlen check
This commit is contained in:
parent
585d63b30d
commit
a49f951c86
@ -68,6 +68,7 @@ int netlib_parsehttpurl(FAR const char *url, FAR uint16_t *port,
|
|||||||
FAR char *dest;
|
FAR char *dest;
|
||||||
int bytesleft;
|
int bytesleft;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
size_t pathlen;
|
||||||
|
|
||||||
/* A valid HTTP URL must begin with http:// if it does not, we will assume
|
/* A valid HTTP URL must begin with http:// if it does not, we will assume
|
||||||
* that it is a file name only, but still return an error. wget() depends
|
* that it is a file name only, but still return an error. wget() depends
|
||||||
@ -154,7 +155,17 @@ int netlib_parsehttpurl(FAR const char *url, FAR uint16_t *port,
|
|||||||
|
|
||||||
/* The copy the rest of the file name to the user buffer */
|
/* The copy the rest of the file name to the user buffer */
|
||||||
|
|
||||||
strncpy(dest, src, bytesleft);
|
pathlen = strlen(src);
|
||||||
filename[namelen-1] = '\0';
|
if (bytesleft >= pathlen + 1)
|
||||||
|
{
|
||||||
|
memcpy(dest, src, pathlen);
|
||||||
|
dest[pathlen] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dest[0] = '\0';
|
||||||
|
ret = -E2BIG;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user