Browse Source

core: parser sdp - check field length when extracting the value

(cherry picked from commit e802f9187383feb7fdd96c4ded44fda403da4535)
Daniel-Constantin Mierla 11 months ago
parent
commit
e650ace594
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/core/parser/sdp/sdp_helpr_funcs.c

+ 7 - 4
src/core/parser/sdp/sdp_helpr_funcs.c

@@ -346,13 +346,16 @@ int extract_candidate(str *body, sdp_stream_cell_t *stream)
 }
 }
 
 
 
 
-/* generic method for attribute extraction
+/* generic method for attribute value extraction
  * field must has format "a=attrname:" */
  * field must has format "a=attrname:" */
 int extract_field(str *body, str *value, str field)
 int extract_field(str *body, str *value, str field)
 {
 {
-	if(strncmp(body->s, field.s, field.len < body->len ? field.len : body->len)
-			!= 0) {
-		/*LM_DBG("We are not pointing to an %.* attribute =>`%.*s'\n", field.len, field.s, body->len, body->s); */
+	if(body->len < field.len) {
+		return -1;
+	}
+	if(strncmp(body->s, field.s, field.len) != 0) {
+		/* LM_DBG("We are not pointing to an %.* attribute =>`%.*s'\n",
+				field.len, field.s, body->len, body->s); */
 		return -1;
 		return -1;
 	}
 	}