Browse Source

core: parse uri - sanity check for user part

Daniel-Constantin Mierla 3 năm trước cách đây
mục cha
commit
eda4b3c51c
1 tập tin đã thay đổi với 9 bổ sung1 xóa
  1. 9 1
      src/core/parser/parse_uri.c

+ 9 - 1
src/core/parser/parse_uri.c

@@ -1236,8 +1236,16 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
 			break; /* do nothing, avoids a compilation warning */
 	}
 
-	if(uri->port.len>5)
+	/* common sanity checks */
+	if(uri->port.len>5) {
+		/* port value to large */
 		goto error_invalid_port;
+	}
+	if(uri->host.len>0 && uri->host.s>buf && *(uri->host.s-1)=='@'
+			&& uri->user.len<=0) {
+		/* '@' before host, but no user part */
+		goto error_bad_uri;
+	}
 
 #ifdef EXTRA_DEBUG
 	/* do stuff */