From 55c6efeca8cf1106f1525c038913014ec5804bc3 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Mon, 9 Mar 2015 18:01:34 +0100 Subject: [PATCH] coap_split_uri: Check if port number is in valid range This change is made to resolve the failed URI parser test t_parse_uri5() --- src/uri.c | 6 ++++++ 1 file changed, 6 insertions(+) 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; } }