浏览代码

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

- reported by Vasiliy Ganchev
Daniel-Constantin Mierla 9 年之前
父节点
当前提交
12160de3c2
共有 1 个文件被更改,包括 5 次插入3 次删除
  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);