core: parse uri - check for invalid port values
authorDaniel-Constantin Mierla <miconda@gmail.com>
Sat, 3 Apr 2021 05:55:11 +0000 (07:55 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Tue, 13 Apr 2021 06:22:35 +0000 (08:22 +0200)
(cherry picked from commit b7f753ddc727e1d7ab42e7abe607059e03976f8d)

src/core/config.h
src/core/parser/parse_uri.c

index 06fe5cb..81fe101 100644 (file)
@@ -95,6 +95,7 @@
 #define MY_BRANCH ";branch="
 #define MY_BRANCH_LEN (sizeof(MY_BRANCH) - 1)
 
+#define MAX_PORT_VAL 65535
 #define MAX_PORT_LEN 7 /* ':' + max 5 letters + \0 */
 
 #define CRLF "\r\n"
index 2c24054..19f6f2e 100644 (file)
@@ -143,6 +143,9 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
 #define case_port( ch, var) \
        case ch: \
                        (var)=(var)*10+ch-'0'; \
+                       if((var) > MAX_PORT_VAL) { \
+                               goto error_bad_port; \
+                       }\
                        break
 
 #define still_at_user  \