Ignore:
Timestamp:
Mar 18, 2009 6:24:40 PM (15 years ago)
Author:
bennylp
Message:

More ticket #747: the previous fix in r2505 causes parsing IPv6 address in Via to fail. Also added some torture messages in the SIP message test vectors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_parser.c

    r2505 r2522  
    326326    pj_cis_del_str(&pconst.pjsip_TOKEN_SPEC_ESC, "%"); 
    327327 
     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 
    328336    status = pj_cis_dup(&pconst.pjsip_HOST_SPEC, &pconst.pjsip_ALNUM_SPEC); 
    329337    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     
    771779    const char *line; 
    772780    int content_length = -1; 
     781    pj_str_t cur_msg; 
     782    const pj_str_t end_hdr = { "\n\r\n", 3}; 
    773783 
    774784    *msg_size = size; 
     
    780790 
    781791 
    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); 
    784798    if (pos == NULL) { 
    785799        return PJSIP_EPARTIALMSG; 
     
    790804 
    791805    /* Find "Content-Length" header the hard way. */ 
    792     line = pj_ansi_strchr(buf, '\n'); 
     806    line = pj_strchr(&cur_msg, '\n'); 
    793807    while (line && line < hdr_end) { 
    794808        ++line; 
     
    841855 
    842856        /* 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'); 
    844860    } 
    845861 
     
    16531669 
    16541670        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)) 
    16561672            break; 
    16571673        /* mangled, get next fraction */ 
     
    19831999        //              &pconst.pjsip_TOKEN_SPEC, 
    19842000        //              &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); 
    19862010 
    19872011        if (!parser_stricmp(pname, pconst.pjsip_BRANCH_STR) && pvalue.slen) { 
Note: See TracChangeset for help on using the changeset viewer.