Changeset 2522 for pjproject/trunk
- Timestamp:
- Mar 18, 2009 6:24:40 PM (16 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_parser.h
r2394 r2522 337 337 pj_cis_t pjsip_TOKEN_SPEC; /**< Token. */ 338 338 pj_cis_t pjsip_TOKEN_SPEC_ESC; /**< Token without '%' character */ 339 pj_cis_t pjsip_VIA_PARAM_SPEC; /**< Via param is token + ":" for 340 IPv6. */ 341 pj_cis_t pjsip_VIA_PARAM_SPEC_ESC; /**< .. as above without '%' */ 339 342 pj_cis_t pjsip_HEX_SPEC; /**< Hexadecimal digits. */ 340 343 pj_cis_t pjsip_PARAM_CHAR_SPEC; /**< For scanning pname (or pvalue -
pjproject/trunk/pjsip/src/pjsip/sip_parser.c
r2505 r2522 326 326 pj_cis_del_str(&pconst.pjsip_TOKEN_SPEC_ESC, "%"); 327 327 328 status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC, &pconst.pjsip_TOKEN_SPEC); 329 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 330 pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC, ":"); 331 332 status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC_ESC, &pconst.pjsip_TOKEN_SPEC_ESC); 333 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 334 pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC, ":"); 335 328 336 status = pj_cis_dup(&pconst.pjsip_HOST_SPEC, &pconst.pjsip_ALNUM_SPEC); 329 337 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); … … 771 779 const char *line; 772 780 int content_length = -1; 781 pj_str_t cur_msg; 782 const pj_str_t end_hdr = { "\n\r\n", 3}; 773 783 774 784 *msg_size = size; … … 780 790 781 791 782 /* Find the end of header area by finding an empty line. */ 783 pos = pj_ansi_strstr(buf, "\n\r\n"); 792 /* Find the end of header area by finding an empty line. 793 * Don't use plain strstr() since we want to be able to handle 794 * NULL character in the message 795 */ 796 cur_msg.ptr = (char*)buf; cur_msg.slen = size; 797 pos = pj_strstr(&cur_msg, &end_hdr); 784 798 if (pos == NULL) { 785 799 return PJSIP_EPARTIALMSG; … … 790 804 791 805 /* Find "Content-Length" header the hard way. */ 792 line = pj_ ansi_strchr(buf, '\n');806 line = pj_strchr(&cur_msg, '\n'); 793 807 while (line && line < hdr_end) { 794 808 ++line; … … 841 855 842 856 /* Go to next line. */ 843 line = pj_ansi_strchr(line, '\n'); 857 cur_msg.slen -= (line - cur_msg.ptr); 858 cur_msg.ptr = (char*)line; 859 line = pj_strchr(&cur_msg, '\n'); 844 860 } 845 861 … … 1653 1669 1654 1670 pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &hdr->hvalue); 1655 if ( IS_NEWLINE(*scanner->curptr))1671 if (pj_scan_is_eof(scanner) || IS_NEWLINE(*scanner->curptr)) 1656 1672 break; 1657 1673 /* mangled, get next fraction */ … … 1983 1999 // &pconst.pjsip_TOKEN_SPEC, 1984 2000 // &pconst.pjsip_TOKEN_SPEC_ESC, 0); 1985 int_parse_param(scanner, pool, &pname, &pvalue, 0); 2001 //int_parse_param(scanner, pool, &pname, &pvalue, 0); 2002 // This should be the correct one: 2003 // added special spec for Via parameter, basically token plus 2004 // ":" to allow IPv6 address in the received param. 2005 pj_scan_get_char(scanner); 2006 parse_param_imp(scanner, pool, &pname, &pvalue, 2007 &pconst.pjsip_VIA_PARAM_SPEC, 2008 &pconst.pjsip_VIA_PARAM_SPEC_ESC, 2009 0); 1986 2010 1987 2011 if (!parser_stricmp(pname, pconst.pjsip_BRANCH_STR) && pvalue.slen) { -
pjproject/trunk/pjsip/src/test-pjsip/msg_test.c
r2433 r2522 74 74 "\r\n", 75 75 &create_msg0, 76 0, 76 77 PJ_SUCCESS 77 78 }, … … 101 102 "a=rtpmap:0 PCMU/8000\r\n", 102 103 &create_msg1, 104 0, 105 PJ_SUCCESS 106 }, 107 { 108 /* Torture message from RFC 4475 109 * 3.1.1.1 A short tortuous INVITE 110 */ 111 "INVITE sip:vivekg@chair-dnrc.example.com;unknownparam SIP/2.0\n" 112 "TO :\n" 113 " sip:vivekg@chair-dnrc.example.com ; tag = 1918181833n\n" 114 "from : \"J Rosenberg \\\\\\\"\" <sip:jdrosen@example.com>\n" 115 " ;\n" 116 " tag = 98asjd8\n" 117 "MaX-fOrWaRdS: 0068\n" 118 "Call-ID: wsinv.ndaksdj@192.0.2.1\n" 119 "Content-Length : 150\n" 120 "cseq: 0009\n" 121 " INVITE\n" 122 "Via : SIP / 2.0\n" 123 " /UDP\n" 124 " 192.0.2.2;rport;branch=390skdjuw\n" 125 "s :\n" 126 "NewFangledHeader: newfangled value\n" 127 " continued newfangled value\n" 128 "UnknownHeaderWithUnusualValue: ;;,,;;,;\n" 129 "Content-Type: application/sdp\n" 130 "Route:\n" 131 " <sip:services.example.com;lr;unknownwith=value;unknown-no-value>\n" 132 "v: SIP / 2.0 / TCP spindle.example.com ;\n" 133 " branch = z9hG4bK9ikj8 ,\n" 134 " SIP / 2.0 / UDP 192.168.255.111 ; branch=\n" 135 " z9hG4bK30239\n" 136 "m:\"Quoted string \\\"\\\"\" <sip:jdrosen@example.com> ; newparam =\n" 137 " newvalue ;\n" 138 " secondparam ; q = 0.33\r\n" 139 "\r\n" 140 "v=0\r\n" 141 "o=mhandley 29739 7272939 IN IP4 192.0.2.3\r\n" 142 "s=-\r\n" 143 "c=IN IP4 192.0.2.4\r\n" 144 "t=0 0\r\n" 145 "m=audio 49217 RTP/AVP 0 12\r\n" 146 "m=video 3227 RTP/AVP 31\r\n" 147 "a=rtpmap:31 LPC\r\n", 148 NULL, 149 0, 150 PJ_SUCCESS 151 }, 152 { 153 /* Torture message from RFC 4475 154 * 3.1.1.2 Wide Range of Valid Characters 155 */ 156 "!interesting-Method0123456789_*+`.%indeed'~ sip:1_unusual.URI~(to-be!sure)&isn't+it$/crazy?,/;;*:&it+has=1,weird!*pas$wo~d_too.(doesn't-it)@example.com SIP/2.0\n" 157 "Via: SIP/2.0/UDP host1.example.com;rport;branch=z9hG4bK-.!%66*_+`'~\n" 158 "To: \"BEL:\\\x07 NUL:\\\x00 DEL:\\\x7F\" <sip:1_unusual.URI~(to-be!sure)&isn't+it$/crazy?,/;;*@example.com>\n" 159 "From: token1~` token2'+_ token3*%!.- <sip:mundane@example.com> ;fromParam''~+*_!.-%=\"\xD1\x80\xD0\xB0\xD0\xB1\xD0\xBE\xD1\x82\xD0\xB0\xD1\x8E\xD1\x89\xD0\xB8\xD0\xB9\";tag=_token~1'+`*%!-.\n" 160 "Call-ID: intmeth.word%ZK-!.*_+'@word`~)(><:\\/\"][?}{\n" 161 "CSeq: 139122385 !interesting-Method0123456789_*+`.%indeed'~\n" 162 "Max-Forwards: 255\n" 163 "extensionHeader-!.%*+_`'~: \xEF\xBB\xBF\xE5\xA4\xA7\xE5\x81\x9C\xE9\x9B\xBB\n" 164 "Content-Length: 0\r\n\r\n", 165 NULL, 166 641, 167 PJ_SUCCESS 168 }, 169 { 170 /* Torture message from RFC 4475 171 * 3.1.1.3 Valid Use of the % Escaping Mechanism 172 */ 173 "INVITE sip:sips%3Auser%40example.com@example.net SIP/2.0\n" 174 "To: sip:%75se%72@example.com\n" 175 "From: <sip:I%20have%20spaces@example.net>;tag=1234\n" 176 "Max-Forwards: 87\n" 177 "i: esc01.239409asdfakjkn23onasd0-3234\n" 178 "CSeq: 234234 INVITE\n" 179 "Via: SIP/2.0/UDP host5.example.net;rport;branch=z9hG4bKkdjuw\n" 180 "C: application/sdp\n" 181 "Contact:\n" 182 " <sip:cal%6Cer@192.168.0.2:5060;%6C%72;n%61me=v%61lue%25%34%31>\n" 183 "Content-Length: 150\r\n" 184 "\r\n" 185 "v=0\r\n" 186 "o=mhandley 29739 7272939 IN IP4 192.0.2.1\r\n" 187 "s=-\r\n" 188 "c=IN IP4 192.0.2.1\r\n" 189 "t=0 0\r\n" 190 "m=audio 49217 RTP/AVP 0 12\r\n" 191 "m=video 3227 RTP/AVP 31\r\n" 192 "a=rtpmap:31 LPC\r\n", 193 NULL, 194 0, 195 PJ_SUCCESS 196 }, 197 { 198 /* Torture message from RFC 4475 199 * 3.1.1.4 Escaped Nulls in URIs 200 */ 201 "REGISTER sip:example.com SIP/2.0\r\n" 202 "To: sip:null-%00-null@example.com\r\n" 203 "From: sip:null-%00-null@example.com;tag=839923423\r\n" 204 "Max-Forwards: 70\r\n" 205 "Call-ID: escnull.39203ndfvkjdasfkq3w4otrq0adsfdfnavd\r\n" 206 "CSeq: 14398234 REGISTER\r\n" 207 "Via: SIP/2.0/UDP host5.example.com;rport;branch=z9hG4bKkdjuw\r\n" 208 "Contact: <sip:%00@host5.example.com>\r\n" 209 "Contact: <sip:%00%00@host5.example.com>\r\n" 210 "L:0\r\n" 211 "\r\n", 212 NULL, 213 0, 214 PJ_SUCCESS 215 }, 216 { 217 /* Torture message from RFC 4475 218 * 3.1.1.5 Use of % When It Is Not an Escape 219 */ 220 "RE%47IST%45R sip:registrar.example.com SIP/2.0\r\n" 221 "To: \"%Z%45\" <sip:resource@example.com>\r\n" 222 "From: \"%Z%45\" <sip:resource@example.com>;tag=f232jadfj23\r\n" 223 "Call-ID: esc02.asdfnqwo34rq23i34jrjasdcnl23nrlknsdf\r\n" 224 "Via: SIP/2.0/TCP host.example.com;rport;branch=z9hG4bK209%fzsnel234\r\n" 225 "CSeq: 29344 RE%47IST%45R\r\n" 226 "Max-Forwards: 70\r\n" 227 "Contact: <sip:alias1@host1.example.com>\r\n" 228 "C%6Fntact: <sip:alias2@host2.example.com>\r\n" 229 "Contact: <sip:alias3@host3.example.com>\r\n" 230 "l: 0\r\n" 231 "\r\n", 232 NULL, 233 0, 103 234 PJ_SUCCESS 104 235 } … … 127 258 enum { BUFLEN = 512 }; 128 259 129 entry->len = pj_ansi_strlen(entry->msg); 260 if (entry->len==0) 261 entry->len = pj_ansi_strlen(entry->msg); 130 262 131 263 if (var.flag & FLAG_PARSE_ONLY) … … 181 313 pj_add_timestamp(&var.parse_time, &t2); 182 314 183 if ( var.flag & FLAG_PARSE_ONLY)315 if ((var.flag & FLAG_PARSE_ONLY) || entry->creator==NULL) 184 316 return PJ_SUCCESS; 185 317
Note: See TracChangeset
for help on using the changeset viewer.