mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #18723 from benpicco/sock_util-find_hoststart
sys/net/sock_util: fix _find_hoststart()
This commit is contained in:
commit
2476a3b3a7
@ -90,7 +90,7 @@ static char* _find_hoststart(const char *url)
|
||||
*/
|
||||
size_t remaining = CONFIG_SOCK_SCHEME_MAXLEN + 1;
|
||||
char *urlpos = (char*)url;
|
||||
while(*urlpos && remaining) {
|
||||
while (*urlpos && remaining) {
|
||||
remaining--;
|
||||
if (*urlpos++ == ':') {
|
||||
if (strncmp(urlpos, "//", 2) == 0) {
|
||||
@ -98,7 +98,6 @@ static char* _find_hoststart(const char *url)
|
||||
}
|
||||
break;
|
||||
}
|
||||
urlpos++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -107,7 +106,7 @@ static char* _find_pathstart(const char *url)
|
||||
{
|
||||
size_t remaining = CONFIG_SOCK_HOSTPORT_MAXLEN;
|
||||
char *urlpos = (char*)url;
|
||||
while(*urlpos && remaining) {
|
||||
while (*urlpos && remaining) {
|
||||
remaining--;
|
||||
if (*urlpos == '/') {
|
||||
return urlpos;
|
||||
@ -184,7 +183,7 @@ int _parse_netif(sock_udp_ep_t *ep_out, char *netifstart)
|
||||
char netifbuf[NETIF_STR_LEN + 1] = {0};
|
||||
|
||||
for (netifend = netifstart; *netifend && *netifend != ']';
|
||||
netifend++);
|
||||
netifend++) {}
|
||||
netiflen = netifend - netifstart;
|
||||
if (!*netifend || (netiflen >= NETIF_STR_LEN) || (netiflen == 0)) {
|
||||
/* no netif found, bail out */
|
||||
@ -213,7 +212,7 @@ int sock_tl_str2ep(struct _sock_tl_ep *ep_out, const char *str)
|
||||
brackets_flag = 1;
|
||||
for (hostend = ++hoststart;
|
||||
*hostend && *hostend != ']' && *hostend != '%';
|
||||
hostend++);
|
||||
hostend++) {}
|
||||
if (! *hostend || ((size_t)(hostend - hoststart) >= sizeof(hostbuf))) {
|
||||
/* none found, bail out */
|
||||
return -EINVAL;
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define TEST_URL_DNS_HOSTPART "test.local"
|
||||
#define TEST_URL_INVALID "[2001:db8::1]://local"
|
||||
#define TEST_URL_INVALID2 "[2001:db8::1]/local"
|
||||
#define TEST_URL_LONG_HOSTPORT "http://veryveryvery.long.hostname.that." \
|
||||
#define TEST_URL_LONG_HOSTPORT "https://veryveryvery.long.hostname.that." \
|
||||
"doesnt.fit.inside.sixtyfour.characters." \
|
||||
"of.buffer.space/localpart"
|
||||
#define TEST_URL_LONG_URLPATH "http://shorthostname/very/very/long/ " \
|
||||
|
Loading…
Reference in New Issue
Block a user