[sr-dev] [kamailio/kamailio] IPv6 parse_uri error (#1136)

doncarr notifications at github.com
Wed Jun 21 23:20:05 CEST 2017


@linuxmaniac, @miconda, I work with @davidxbwang 

I found the issue in modules/pv/pv_core.c. Function pv_get_srcip(). We should substitute the function ip_addr2strz() for ip_addr2a(). ip_addr2strz() correctly inserts the [] in the string when the address is IPv6. Also, I noticed that both of these functions use a static buffer that is one character too small. Since they put a null terminator, if you have a maximum size IPv6 address (no leading zeros) you will overwrite the end of the buffer. 

We tested the fix, and, it appears to not affect other parts of the code that might not expect the brackets [] added.  

Below the fix is shown with the old line commented out.

int pv_get_srcip(struct sip_msg *msg, pv_param_t *param,
                pv_value_t *res)
{
        str s;
        if(msg==NULL)
                return -1;
 
        //s.s = ip_addr2a(&msg->rcv.src_ip);
        s.s = ip_addr2strz(&msg->rcv.src_ip);
        s.len = strlen(s.s);
        return pv_get_strval(msg, param, res, &s);
}
 
Don.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1136#issuecomment-310208571
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20170621/2425aa05/attachment.html>


More information about the sr-dev mailing list