received param is not added to the Via header in cases when host IP in Via1 header is a substring of src_ip

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

received param is not added to the Via header in cases when host IP in Via1 header is a substring of src_ip

Kuzmenok, Vladimir

Hello All,

 

We have an issue with the opensips 1.11.5-tls. Received header is not added to the Via header even when src IP and IP in the Via1 header are different.

 

Here is an example

 

Src IP is 192.168.1.121

IP in Via is 192.168.1.12

 

Looking into the code of opensips/msg_translator.c I can see that check_ip_address function  from opensips/resolve.c is used. It looks like there is a bug in the function, which returns 0 for the cases like above, because comparison is done only up to the Via host length and length of IP is not taken into consideration

 

=========================================================================================

int check_ip_address(struct ip_addr* ip, str *name,

                                                                unsigned short port, unsigned short proto, int resolver)

{

                struct hostent* he;

                int i, len;

                char* s;

 

                /* maybe we are lucky and name it's an ip */

                s=ip_addr2a(ip);

                if (s){

                                LM_DBG("params %s, %.*s, %d\n", s, name->len, name->s, resolver);

                                len=strlen(s);

 

                                /* check if name->s is an ipv6 address or an ipv6 address ref. */

                                if ((ip->af==AF_INET6) &&

                                                                (              ((len==name->len)&&(strncasecmp(name->s, s, name->len)==0))

                                                                                ||

                                                                                ((len==(name->len-2))&&(name->s[0]=='[')&&

                                                                                                (name->s[name->len-1]==']')&&

                                                                                                (strncasecmp(name->s+1, s, len)==0))

                                                                )

                                   )

                                                return 0;

                                else

 

                                                if (strncmp(name->s, s, name->len)==0)

                                                                return 0;

                }else{

                                LM_CRIT("could not convert ip address\n");

                                return -1;

                }

 

==========================================================================================

 

The easies fix would be just add (len == name->len) as a first condition with &&  conjunction to the highlighted if statement .

Could you please check and issue a patch for this?

 

 

Thanks,

Vladimir

 

 

 






IPC ranks #33 in IDC's Top 100 FinTech

DISCLAIMER: This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unintended recipients are prohibited from taking action on the basis of information in this e-mail. E-mail messages may contain computer viruses or other defects, may not be accurately replicated on other systems, or may be intercepted, deleted or interfered with without the knowledge of the sender or the intended recipient. If you are not comfortable with the risks associated with e-mail messages, you may decide not to use e-mail to communicate with IPC. IPC reserves the right, to the extent and under circumstances permitted by applicable law, to retain, monitor and intercept e-mail messages to and from its systems.


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users