Changeset 1800 for pjproject


Ignore:
Timestamp:
Feb 15, 2008 5:26:47 PM (17 years ago)
Author:
bennylp
Message:

Ticket #482: TCP keep-alive packets are corrupting SIP message (thanks Helmut Wolf)

File:
1 edited

Legend:

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

    r1634 r1800  
    12711271    if (rdata->pkt_info.len <= 0) 
    12721272        return -1; 
    1273      
     1273 
    12741274    current_pkt = rdata->pkt_info.packet; 
    12751275    remaining_len = rdata->pkt_info.len; 
     
    12841284 
    12851285        pjsip_msg *msg; 
     1286        char *p, *end; 
     1287        char saved; 
    12861288        pj_size_t msg_fragment_size; 
     1289 
     1290        /* Skip leading newlines as pjsip_find_msg() currently can't 
     1291         * handle leading newlines. 
     1292         */ 
     1293        for (p=current_pkt, end=p+remaining_len; p!=end; ++p) { 
     1294            if (*p != '\r' && *p != '\n') 
     1295                break; 
     1296        } 
     1297        if (p!=current_pkt) { 
     1298            remaining_len -= (p - current_pkt); 
     1299            total_processed += (p - current_pkt); 
     1300            current_pkt = p; 
     1301            if (remaining_len == 0) { 
     1302                return total_processed; 
     1303            } 
     1304        } 
    12871305 
    12881306        /* Initialize default fragment size. */ 
    12891307        msg_fragment_size = remaining_len; 
    1290  
    1291         /* Null terminate packet. */ 
    12921308 
    12931309        /* Clear and init msg_info in rdata.  
     
    13201336        rdata->msg_info.len = msg_fragment_size; 
    13211337 
     1338        /* Null terminate packet */ 
     1339        saved = current_pkt[msg_fragment_size]; 
     1340        current_pkt[msg_fragment_size] = '\0'; 
     1341 
    13221342        /* Parse the message. */ 
    13231343        rdata->msg_info.msg = msg =  
    13241344            pjsip_parse_rdata( current_pkt, msg_fragment_size, rdata); 
     1345 
     1346        /* Restore null termination */ 
     1347        current_pkt[msg_fragment_size] = saved; 
    13251348 
    13261349        /* Check for parsing syntax error */ 
Note: See TracChangeset for help on using the changeset viewer.