Browse code

core: parse uri - cast to unsigned for left shifting

(cherry picked from commit d4e31e6ae494836c49e50f463517a576b18c5611)
(cherry picked from commit 8622811124f641b6a4b09a802758a354556850b0)

Daniel-Constantin Mierla authored on 02/04/2021 07:37:21 • Henning Westerholt committed on 22/10/2021 11:33:18
Showing 1 changed files
... ...
@@ -26,6 +26,8 @@
26 26
  */
27 27
 
28 28
 
29
+#include <stdint.h>
30
+
29 31
 #include "../globals.h"
30 32
 #include "parse_uri.h"
31 33
 #include <string.h>
... ...
@@ -105,7 +107,7 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
105 107
 	char* pass;
106 108
 	int found_user;
107 109
 	int error_headers;
108
-	unsigned int scheme;
110
+	uint32_t scheme;
109 111
 	uri_type backup_urit;
110 112
 	uri_flags backup_urif;
111 113
 
... ...
@@ -367,9 +369,10 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
367 369
 	port_no=0;
368 370
 	state=URI_INIT;
369 371
 	memset(uri, 0, sizeof(struct sip_uri)); /* zero it all, just to be sure*/
370
-	/*look for sip:, sips: ,tel: or urn:*/
372
+	/*look for sip:, sips:, tel: or urn:*/
371 373
 	if (len<5) goto error_too_short;
372
-	scheme=buf[0]+(buf[1]<<8)+(buf[2]<<16)+(buf[3]<<24);
374
+	scheme=((uint32_t)buf[0]) + (((uint32_t)buf[1])<<8)
375
+				+ (((uint32_t)buf[2])<<16) + (((uint32_t)buf[3])<<24);
373 376
 	scheme|=0x20202020;
374 377
 	if (scheme==SIP_SCH){
375 378
 		uri->type=SIP_URI_T;