Browse code

core: parse uri - check for invalid port values

(cherry picked from commit b7f753ddc727e1d7ab42e7abe607059e03976f8d)
(cherry picked from commit 3dca9d6bff8e08677a02e3bb0f47b4c0889f2cca)

Daniel-Constantin Mierla authored on 03/04/2021 05:55:11 • Henning Westerholt committed on 22/10/2021 11:33:31
Showing 2 changed files
... ...
@@ -93,6 +93,7 @@
93 93
 #define MY_BRANCH ";branch="
94 94
 #define MY_BRANCH_LEN (sizeof(MY_BRANCH) - 1)
95 95
 
96
+#define MAX_PORT_VAL 65535
96 97
 #define MAX_PORT_LEN 7 /* ':' + max 5 letters + \0 */
97 98
 
98 99
 #define CRLF "\r\n"
... ...
@@ -124,6 +124,9 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
124 124
 #define case_port( ch, var) \
125 125
 	case ch: \
126 126
 			(var)=(var)*10+ch-'0'; \
127
+			if((var) > MAX_PORT_VAL) { \
128
+				goto error_bad_port; \
129
+			}\
127 130
 			break
128 131
 
129 132
 #define still_at_user  \