Browse code

core: parse uri - check for invalid port values

Daniel-Constantin Mierla authored on 03/04/2021 05:55:11
Showing 2 changed files
... ...
@@ -96,6 +96,7 @@
96 96
 #define MY_BRANCH ";branch="
97 97
 #define MY_BRANCH_LEN (sizeof(MY_BRANCH) - 1)
98 98
 
99
+#define MAX_PORT_VAL 65535
99 100
 #define MAX_PORT_LEN 7 /* ':' + max 5 letters + \0 */
100 101
 
101 102
 #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  \