Browse code

secfilter: avoid dereferences null

Jose Luis Verdeguer authored on 12/03/2019 09:03:26
Showing 1 changed files
... ...
@@ -424,6 +424,10 @@ static int check_user(struct sip_msg *msg, int type)
424 424
 	if(res != 0) {
425 425
 		return res;
426 426
 	}
427
+	
428
+	if (user.s == NULL || domain.s == NULL) {
429
+		return -1;
430
+	}
427 431
 
428 432
 	nlen = name.len;
429 433
 	ulen = user.len;
... ...
@@ -434,9 +438,11 @@ static int check_user(struct sip_msg *msg, int type)
434 434
 	while(list) {
435 435
 		if(name.len > list->s.len)
436 436
 			name.len = list->s.len;
437
-		res = cmpi_str(&list->s, &name);
438
-		if(res == 0) {
439
-			return 4;
437
+		if (name.s != NULL) {
438
+			res = cmpi_str(&list->s, &name);
439
+			if(res == 0) {
440
+				return 4;
441
+			}
440 442
 		}
441 443
 		if(user.len > list->s.len)
442 444
 			user.len = list->s.len;
... ...
@@ -453,9 +459,11 @@ static int check_user(struct sip_msg *msg, int type)
453 453
 	while(list) {
454 454
 		if(name.len > list->s.len)
455 455
 			name.len = list->s.len;
456
-		res = cmpi_str(&list->s, &name);
457
-		if(res == 0) {
458
-			return -4;
456
+		if (name.s != NULL) {
457
+			res = cmpi_str(&list->s, &name);
458
+			if(res == 0) {
459
+				return -4;
460
+			}
459 461
 		}
460 462
 		if(user.len > list->s.len)
461 463
 			user.len = list->s.len;