Module: kamailio
Branch: master
Commit: 2cb94f28d7d214d22ccdb6a5b993b391f61ea15b
URL:
https://github.com/kamailio/kamailio/commit/2cb94f28d7d214d22ccdb6a5b993b39…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-11-17T14:33:46+01:00
core: test if ipv6 address starts with [ for subst snd lumps
- safer than the test against cached socket address known to be without
[], allowing to pass any address value to be used
- reported by GH #1315
---
Modified: src/core/msg_translator.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2cb94f28d7d214d22ccdb6a5b993b39…
Patch:
https://github.com/kamailio/kamailio/commit/2cb94f28d7d214d22ccdb6a5b993b39…
---
diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index 725d6290c9..ca0f9fa521 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -678,8 +678,8 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps,
case SUBST_SND_IP: \
if (send_sock){ \
new_len+=send_address_str->len; \
- if (send_sock->address.af!=AF_INET && \
- send_address_str==&(send_sock->address_str)) \
+ if (send_sock->address.af==AF_INET6 && \
+ send_address_str->s[0]!='[') \
new_len+=2; \
}else{ \
LM_CRIT("FIXME: null send_sock\n"); \
@@ -724,8 +724,8 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps,
case SUBST_SND_ALL: \
if (send_sock){ \
new_len+=send_address_str->len; \
- if ((send_sock->address.af!=AF_INET) && \
- (send_address_str==&(send_sock->address_str))) \
+ if ((send_sock->address.af==AF_INET6) && \
+ (send_address_str->s[0]!='[')) \
new_len+=2; \
if ((send_sock->port_no!=SIP_PORT) || \
(send_port_str!=&(send_sock->port_no_str))){ \
@@ -766,7 +766,7 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps,
default: \
LM_CRIT("unknown subst type %d\n", (subst_l)->u.subst); \
}
-
+
if (send_info){
send_sock=send_info->send_sock;
}else{
@@ -935,7 +935,7 @@ void process_lumps( struct sip_msg* msg,
default:\
LM_CRIT("unknown comp %d\n", msg->rcv.comp); \
}
-
+
#define SENDCOMP_PARAM_ADD \
/* add ;comp=xxxx */ \
switch(send_info->comp){ \
@@ -956,7 +956,7 @@ void process_lumps( struct sip_msg* msg,
break;\
default:\
LM_CRIT("unknown comp %d\n", msg->rcv.comp); \
- }
+ }
#else
#define RCVCOMP_PARAM_ADD
#define SENDCOMP_PARAM_ADD
@@ -1057,14 +1057,14 @@ void process_lumps( struct sip_msg* msg,
case SUBST_SND_IP: \
if (send_sock){ \
if ((send_sock->address.af!=AF_INET) && \
- (send_address_str==&(send_sock->address_str))){\
+ (send_address_str->s[0]!='[')){\
new_buf[offset]='['; offset++; \
}\
memcpy(new_buf+offset, send_address_str->s, \
send_address_str->len); \
offset+=send_address_str->len; \
if ((send_sock->address.af!=AF_INET) && \
- (send_address_str==&(send_sock->address_str))){\
+ (send_address_str->s[0]!='[')){\
new_buf[offset]=']'; offset++; \
}\
}else{ \
@@ -1086,14 +1086,14 @@ void process_lumps( struct sip_msg* msg,
if (send_sock){ \
/* address */ \
if ((send_sock->address.af!=AF_INET) && \
- (send_address_str==&(send_sock->address_str))){\
+ (send_address_str->s[0]!='[')){\
new_buf[offset]='['; offset++; \
}\
memcpy(new_buf+offset, send_address_str->s, \
send_address_str->len); \
offset+=send_address_str->len; \
if ((send_sock->address.af!=AF_INET) && \
- (send_address_str==&(send_sock->address_str))){\
+ (send_address_str->s[0]!='[')){\
new_buf[offset]=']'; offset++; \
}\
/* :port */ \