Browse Source

core: skip zero char and whitespaces before parsing first line in parse_msg()

- reported by Vasiliy Ganchev
Daniel-Constantin Mierla 9 years ago
parent
commit
12160de3c2
1 changed files with 5 additions and 3 deletions
  1. 5 3
      parser/msg_parser.c

+ 5 - 3
parser/msg_parser.c

@@ -589,9 +589,11 @@ int parse_msg(char* const buf, const unsigned int len, struct sip_msg* const msg
 	int offset;
 	hdr_flags_t flags;
 
-	/* eat crlf from the beginning */
-	for (tmp=buf; (*tmp=='\n' || *tmp=='\r')&&
-			tmp-buf < len ; tmp++);
+	/* eat crlf & whitespaces from the beginning */
+	for (tmp=buf; (tmp-buf < len)
+			&& (*tmp=='\n' || *tmp=='\r' || *tmp=='\0'
+				|| *tmp=='\t' || *tmp==' ');
+			tmp++);
 	offset=tmp-buf;
 	fl=&(msg->first_line);
 	rest=parse_first_line(tmp, len-offset, fl);