Changeset 2985


Ignore:
Timestamp:
Nov 4, 2009 1:17:31 PM (10 years ago)
Author:
bennylp
Message:

Fixed ticket #940: Multiple header rows with the same name may not be completely processed by PJSIP modules

  • the parser now collect and aggregate all Supported/Require? header fields into single header
Location:
pjproject/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_transport.h

    r2932 r2985  
    386386        pjsip_clen_hdr          *clen; 
    387387 
    388         /** The first Require header. */ 
     388        /** "Require" header containing aggregates of all Require 
     389         *  headers found in the message, or NULL.  
     390         */ 
    389391        pjsip_require_hdr       *require; 
     392 
     393        /** "Supported" header containing aggregates of all Supported 
     394         *  headers found in the message, or NULL.  
     395         */ 
     396        pjsip_supported_hdr     *supported; 
    390397 
    391398        /** The list of error generated by the parser when parsing  
  • pjproject/trunk/pjsip/src/pjsip/sip_parser.c

    r2695 r2985  
    10081008                hdr = (*handler)(ctx); 
    10091009 
     1010                /* Note: 
     1011                 *  hdr MAY BE NULL, if parsing does not yield a new header 
     1012                 *  instance, e.g. the values have been added to existing 
     1013                 *  header. See http://trac.pjsip.org/repos/ticket/940 
     1014                 */ 
     1015 
    10101016                /* Check if we've just parsed a Content-Type header.  
    10111017                 * We will check for a message body if we've got Content-Type  
    10121018                 * header. 
    10131019                 */ 
    1014                 if (hdr->type == PJSIP_H_CONTENT_TYPE) { 
     1020                if (hdr && hdr->type == PJSIP_H_CONTENT_TYPE) { 
    10151021                    ctype_hdr = (pjsip_ctype_hdr*)hdr; 
    10161022                } 
     
    10281034             * So here we must insert list instead of just insert one header. 
    10291035             */ 
    1030             pj_list_insert_nodes_before(&msg->hdr, hdr); 
     1036            if (hdr) 
     1037                pj_list_insert_nodes_before(&msg->hdr, hdr); 
    10311038             
    10321039            /* Parse until EOF or an empty line is found. */ 
     
    16401647    } 
    16411648 
    1642     pj_scan_get( scanner, &pconst.pjsip_NOT_COMMA_OR_NEWLINE, &hdr->values[0]); 
     1649    if (hdr->count >= PJ_ARRAY_SIZE(hdr->values)) { 
     1650        /* Too many elements */ 
     1651        on_syntax_error(scanner); 
     1652        return; 
     1653    } 
     1654 
     1655    pj_scan_get( scanner, &pconst.pjsip_NOT_COMMA_OR_NEWLINE,  
     1656                 &hdr->values[hdr->count]); 
    16431657    hdr->count++; 
    16441658 
     
    19181932static pjsip_hdr* parse_hdr_require( pjsip_parse_ctx *ctx ) 
    19191933{ 
    1920     pjsip_require_hdr *hdr = pjsip_require_hdr_create(ctx->pool); 
     1934    pjsip_require_hdr *hdr; 
     1935    pj_bool_t new_hdr = (ctx->rdata->msg_info.require == NULL); 
     1936     
     1937    if (ctx->rdata && ctx->rdata->msg_info.require) { 
     1938        hdr = ctx->rdata->msg_info.require; 
     1939    } else { 
     1940        hdr = pjsip_require_hdr_create(ctx->pool); 
     1941        ctx->rdata->msg_info.require = hdr; 
     1942    } 
     1943 
    19211944    parse_generic_array_hdr(hdr, ctx->scanner); 
    19221945 
    1923     if (ctx->rdata && ctx->rdata->msg_info.require == NULL) 
    1924         ctx->rdata->msg_info.require = hdr; 
    1925  
    1926     return (pjsip_hdr*)hdr; 
     1946    return new_hdr ? (pjsip_hdr*)hdr : NULL; 
    19271947} 
    19281948 
     
    19611981static pjsip_hdr* parse_hdr_supported(pjsip_parse_ctx *ctx) 
    19621982{ 
    1963     pjsip_supported_hdr *hdr = pjsip_supported_hdr_create(ctx->pool); 
     1983    pjsip_supported_hdr *hdr; 
     1984    pj_bool_t new_hdr = (ctx->rdata->msg_info.supported == NULL); 
     1985 
     1986    if (ctx->rdata && ctx->rdata->msg_info.supported) { 
     1987        hdr = ctx->rdata->msg_info.supported; 
     1988    } else { 
     1989        hdr = pjsip_supported_hdr_create(ctx->pool); 
     1990        ctx->rdata->msg_info.supported = hdr; 
     1991    } 
     1992 
    19641993    parse_generic_array_hdr(hdr, ctx->scanner); 
    1965     return (pjsip_hdr*)hdr; 
    1966 } 
    1967  
     1994    return new_hdr ? (pjsip_hdr*)hdr : NULL; 
     1995} 
    19681996 
    19691997/* Parse To: header. */ 
Note: See TracChangeset for help on using the changeset viewer.