Browse code

core: parse uri - check for invalid port values

(cherry picked from commit b7f753ddc727e1d7ab42e7abe607059e03976f8d)

Daniel-Constantin Mierla authored on 03/04/2021 05:55:11
Showing 2 changed files
... ...
@@ -95,6 +95,7 @@
95 95
 #define MY_BRANCH ";branch="
96 96
 #define MY_BRANCH_LEN (sizeof(MY_BRANCH) - 1)
97 97
 
98
+#define MAX_PORT_VAL 65535
98 99
 #define MAX_PORT_LEN 7 /* ':' + max 5 letters + \0 */
99 100
 
100 101
 #define CRLF "\r\n"
... ...
@@ -143,6 +143,9 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
143 143
 #define case_port( ch, var) \
144 144
 	case ch: \
145 145
 			(var)=(var)*10+ch-'0'; \
146
+			if((var) > MAX_PORT_VAL) { \
147
+				goto error_bad_port; \
148
+			}\
146 149
 			break
147 150
 
148 151
 #define still_at_user  \