Ticket #832: ticket832.patch

File ticket832.patch, 4.3 KB (added by nanang, 15 years ago)

Added check of internal param 'hide' in route URI

  • pjsip/src/test/msg_test.c

     
    365365    hdr2 = ref_msg->hdr.next; 
    366366 
    367367    while (hdr1 != &parsed_msg->hdr && hdr2 != &ref_msg->hdr) { 
    368         len = hdr1->vptr->print_on(hdr1, str1.ptr, BUFLEN); 
    369         if (len < 1) { 
     368        len = pjsip_hdr_print_on(hdr1, str1.ptr, BUFLEN); 
     369        if (len < 0) { 
    370370            status = -40; 
    371371            goto on_return; 
    372372        } 
    373373        str1.ptr[len] = '\0'; 
    374374        str1.slen = len; 
    375375 
    376         len = hdr2->vptr->print_on(hdr2, str2.ptr, BUFLEN); 
    377         if (len < 1) { 
     376        len = pjsip_hdr_print_on(hdr2, str2.ptr, BUFLEN); 
     377        if (len < 0) { 
    378378            status = -50; 
    379379            goto on_return; 
    380380        } 
     
    19371937        /* Print the parsed header*/ 
    19381938        output = (char*) pj_pool_alloc(pool, 1024); 
    19391939        len = pjsip_hdr_print_on(parsed_hdr1, output, 1024); 
    1940         if (len < 1 || len >= 1024) { 
     1940        if (len < 0 || len >= 1024) { 
    19411941            PJ_LOG(3,(THIS_FILE, "    header too long: %s: %s", test->hname, test->hcontent)); 
    19421942            return -530; 
    19431943        } 
  • pjsip/src/pjsip/sip_msg.c

     
    456456 
    457457    /* Print each of the headers. */ 
    458458    for (hdr=msg->hdr.next; hdr!=&msg->hdr; hdr=hdr->next) { 
    459         len = (*hdr->vptr->print_on)(hdr, p, end-p); 
    460         if (len < 1) 
     459        len = pjsip_hdr_print_on(hdr, p, end-p); 
     460        if (len < 0) 
    461461            return -1; 
    462         p += len; 
    463462 
    464         if (p+3 >= end) 
    465             return -1; 
     463        if (len > 0) { 
     464            p += len; 
     465            if (p+3 >= end) 
     466                return -1; 
    466467 
    467         *p++ = '\r'; 
    468         *p++ = '\n'; 
     468            *p++ = '\r'; 
     469            *p++ = '\n'; 
     470        } 
    469471    } 
    470472 
    471473    /* Process message body. */ 
     
    16011603    char *startbuf = buf; 
    16021604    char *endbuf = buf + size; 
    16031605    const pjsip_parser_const_t *pc = pjsip_parser_const(); 
     1606    char *p; 
     1607 
    16041608    /* Route and Record-Route don't compact forms */ 
    16051609 
    16061610    copy_advance(buf, hdr->name); 
    16071611    *buf++ = ':'; 
    16081612    *buf++ = ' '; 
    16091613 
     1614    p = buf; 
    16101615    printed = pjsip_uri_print(PJSIP_URI_IN_ROUTING_HDR, &hdr->name_addr, buf,  
    16111616                              endbuf-buf); 
    16121617    if (printed < 1) 
    16131618        return -1; 
    16141619    buf += printed; 
    16151620 
     1621    /* Ticket #832:  
     1622     *   Check the proprietary param 'hide', don't print this header  
     1623     *   if it exists in the route URI. 
     1624     */ 
     1625    while(1) { 
     1626        const pj_str_t st_hide = {"hide", 4}; 
     1627        pj_str_t uri_param; 
     1628        char *p2; 
     1629 
     1630        /* Looking for ';' separator. */ 
     1631        while (p < buf && *p != ';') { ++p; } 
     1632        if (p >= buf)  
     1633            break; 
     1634 
     1635        /* Looking for another ';' separator or end-of-URI. */ 
     1636        p2 = ++p; 
     1637        while (p2 < buf && *p2 != ';' && *p2 != '>') { ++p2; } 
     1638 
     1639        pj_strset(&uri_param, p, p2-p); 
     1640        if (pj_stricmp(&uri_param, &st_hide) == 0) { 
     1641            return 0; 
     1642        } 
     1643    } 
     1644 
     1645 
    16161646    printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf,  
    16171647                                   &pc->pjsip_TOKEN_SPEC,  
    16181648                                   &pc->pjsip_TOKEN_SPEC, ';'); 
  • pjsip/src/pjsip/sip_ua_layer.c

     
    907907    char userinfo[128]; 
    908908 
    909909    len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
    910     if (len < 1) 
     910    if (len < 0) 
    911911        pj_ansi_strcpy(userinfo, "<--uri too long-->"); 
    912912    else 
    913913        userinfo[len] = '\0'; 
  • pjsip/src/pjsua-lib/pjsua_call.c

     
    26942694    /* Dump invite sesion info. */ 
    26952695 
    26962696    len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
    2697     if (len < 1) 
     2697    if (len < 0) 
    26982698        pj_ansi_strcpy(userinfo, "<--uri too long-->"); 
    26992699    else 
    27002700        userinfo[len] = '\0'; 
  • pjsip-apps/src/samples/siprtp_report.c

     
    7777 
    7878    /* Call identification */ 
    7979    len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
    80     if (len < 1) 
     80    if (len < 0) 
    8181        pj_ansi_strcpy(userinfo, "<--uri too long-->"); 
    8282    else 
    8383        userinfo[len] = '\0';