Browse code

core: parse uri - cast to unsigned for left shifting

(cherry picked from commit d4e31e6ae494836c49e50f463517a576b18c5611)

Daniel-Constantin Mierla authored on 02/04/2021 07:37:21
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>
... ...
@@ -124,7 +126,7 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
124 126
 	char* pass;
125 127
 	int found_user;
126 128
 	int error_headers;
127
-	unsigned int scheme;
129
+	uint32_t scheme;
128 130
 	uri_type backup_urit;
129 131
 	uri_flags backup_urif;
130 132
 
... ...
@@ -386,9 +388,10 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
386 388
 	port_no=0;
387 389
 	state=URI_INIT;
388 390
 	memset(uri, 0, sizeof(struct sip_uri)); /* zero it all, just to be sure*/
389
-	/*look for sip:, sips: ,tel: or urn:*/
391
+	/*look for sip:, sips:, tel: or urn:*/
390 392
 	if (len<5) goto error_too_short;
391
-	scheme=buf[0]+(buf[1]<<8)+(buf[2]<<16)+(buf[3]<<24);
393
+	scheme=((uint32_t)buf[0]) + (((uint32_t)buf[1])<<8)
394
+				+ (((uint32_t)buf[2])<<16) + (((uint32_t)buf[3])<<24);
392 395
 	scheme|=0x20202020;
393 396
 	if (scheme==SIP_SCH){
394 397
 		uri->type=SIP_URI_T;