diff --git a/src/uri.c b/src/uri.c index b5b8c834..ec6c57ee 100644 --- a/src/uri.c +++ b/src/uri.c @@ -133,6 +133,12 @@ coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) { while (p < q) uri_port = uri_port * 10 + (*p++ - '0'); + /* check if port number is in allowed range */ + if (uri_port > 65535) { + res = -4; + goto error; + } + uri->port = uri_port; } }