mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sock_util: Prevent overflow in sock_urlsplit
This adds a length check to verify if the host-port part of the URL fits in the supplied buffer
This commit is contained in:
parent
3096823ab4
commit
b8a494fb76
@ -126,7 +126,13 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
|
||||
|
||||
char *pathstart = _find_pathstart(hoststart);
|
||||
|
||||
memcpy(hostport, hoststart, pathstart - hoststart);
|
||||
size_t hostlen = pathstart - hoststart;
|
||||
/* hostlen must be smaller SOCK_HOSTPORT_MAXLEN to have space for the null
|
||||
* terminator */
|
||||
if (hostlen > SOCK_HOSTPORT_MAXLEN - 1) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
memcpy(hostport, hoststart, hostlen);
|
||||
|
||||
size_t pathlen = strlen(pathstart);
|
||||
if (pathlen) {
|
||||
|
Loading…
Reference in New Issue
Block a user