Am Samstag, 29. Dezember 2018, 19:34:42 CET schrieb Mojtaba:
> In msg_translator.c source file, goes to check_via_address function in line
> 147,
> In that function, the length of both ip in host(name) and host(ip) is just
> checked in ipv6 (if condition section). the code are here:
>
> /* 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 (unlikely(name->s==NULL)) {
> LM_CRIT("invalid Via host name\n");
> return -1;
> }
>
> if (strncmp(name->s, s, name->len)==0) //I think the length
> would be checked
> return 0;
> }
Hello Mojtaba,
thank you for the report. This looks indeed not correct. I fixed this today in
git master (commit 98ee014a) and will also backport it. I wonder why this was
not found earlier, this is a really old function. But most people probably use
DNS names in their VIAs.
Best regards,
Henning
> But in else section, the length does not check. I think it would be nice to
> check . like this:
>
> if (len == name->len && strncmp(name->s, s, name->len)==0)
>
> Not actually, i am not referring to git master yet. I just want to know do
> it would be nice or not?
> With Regards.Mojtaba Esfandiari.S
>
> > > Does anybody know why the lenght of both ip-address (s and name) in
> > > check_via_address function in msg_translator.c source file dose not
> > > check first?
> > > Actually i think it's better do.
> > > For example if via:192.168.122.1 and src:192.168.122.100, the result
> > > returned true, as they are not the same!
> > > With.Regards. Mojtaba
> >
> > Hello Mojtaba,
> >
> > can you give more details, which line in e.g. git master are you referring
> > to?
--
Henning Westerholt - https://skalatan.de/blog/
Kamailio services - https://skalatan.de/services
Kamailio security assessment - https://skalatan.de/de/assessment
Module: kamailio
Branch: master
Commit: 98ee014a88ca951d82a0389f0be119078ba525f7
URL: https://github.com/kamailio/kamailio/commit/98ee014a88ca951d82a0389f0be1190…
Author: Henning Westerholt <hw(a)kamailio.org>
Committer: Henning Westerholt <hw(a)kamailio.org>
Date: 2018-12-30T01:17:15+01:00
core: fix an error in check_via_address, reported from Mojtaba, mespio at gmail dot com
- fix an error in check_via_address, reported from Mojtaba, mespio at gmail dot com
- use the same logic for IPv4 string comparison as for IPv6
- the old comparison could return true for e.g. via="192.168.1.1", src="192.1.1.100"
- the new logic is also faster for the trivial case with different string length
---
Modified: src/core/msg_translator.c
---
Diff: https://github.com/kamailio/kamailio/commit/98ee014a88ca951d82a0389f0be1190…
Patch: https://github.com/kamailio/kamailio/commit/98ee014a88ca951d82a0389f0be1190…
---
diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index 3bb0dd7bba..c7851904c7 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -179,7 +179,7 @@ static int check_via_address(struct ip_addr* ip, str *name,
LM_CRIT("invalid Via host name\n");
return -1;
}
- if (strncmp(name->s, s, name->len)==0)
+ if (len==name->len&&(strncmp(name->s, s, name->len)==0))
return 0;
}
}else{
Module: kamailio
Branch: master
Commit: 14975b6e7e028aea9db198c64b65526fb9bd20b7
URL: https://github.com/kamailio/kamailio/commit/14975b6e7e028aea9db198c64b65526…
Author: Henning Westerholt <hw(a)kamailio.org>
Committer: Henning Westerholt <hw(a)kamailio.org>
Date: 2018-12-30T00:41:58+01:00
cdp: fix a coverity scan error, duplicated code for logical statement
---
Modified: src/modules/cdp/session.c
---
Diff: https://github.com/kamailio/kamailio/commit/14975b6e7e028aea9db198c64b65526…
Patch: https://github.com/kamailio/kamailio/commit/14975b6e7e028aea9db198c64b65526…
---
diff --git a/src/modules/cdp/session.c b/src/modules/cdp/session.c
index dd5c026e3e..60e97becae 100644
--- a/src/modules/cdp/session.c
+++ b/src/modules/cdp/session.c
@@ -607,8 +607,8 @@ AAASession* cdp_new_cc_acc_session(str id, int is_statefull)
AAASession *s;
cdp_session_type_t type;
- if (is_statefull) type = ACCT_CC_CLIENT;
- else type = ACCT_CC_CLIENT; //for now everything will be supported through this SM (until we add IEC)
+ //for now everything will be supported through this SM (until we add IEC)
+ type = ACCT_CC_CLIENT;
s = cdp_new_session(id,type);
if (s) {
Hello ,
Does anybody know why the lenght of both ip-address (s and name) in
check_via_address function in msg_translator.c source file dose not
check first?
Actually i think it's better do.
For example if via:192.168.122.1 and src:192.168.122.100, the result
returned true, as they are not the same!
With.Regards. Mojtaba
Happy new year
--Mojtaba Esfandiari.S
Hello,
I noticed many commits replacing the log messages in case of allocation
failure with some macros. That is good, bringing consistency, but I
think that we should offer couple of them. The current one is rather dry
(meaning that it offers very few context details), which matches most of
the existing log messages used in such cases.
But there are also other log messages for such cases which give more
details, like for what the allocation fails, some also giving the
requested size of allocation.
So besides the current two macros (one for shm and one for pkg), we
should add few more. Like:
#define PKG_MEM_ERROR_MSG(m) LM_ERR("could not allocate private memory
from pkg pool - %s\n", m);
So one can do:
PKG_MEM_ERROR_MSG("needed for htable struct");
And one to include also the size:
#define PKG_MEM_ERROR_SZ(s, m) LM_ERR("could not allocate private memory
from pkg pool - size: %u - %s\n", (unsigned int)s, m);
No need to revert what was done, but I think for the future we would
preserve better information for troubleshooting in some cases, instead
of replacing those messages that now have more details with the bare
error log message.
Cheers,
Daniel
--
Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - May 6-8, 2019 -- www.kamailioworld.com
Kamailio Advanced Training - Mar 4-6, 2019 in Berlin; Mar 25-27, 2019, in Washington, DC, USA -- www.asipto.com
Module: kamailio
Branch: master
Commit: d3b3e87a2d39992d1da291f552869f14375425de
URL: https://github.com/kamailio/kamailio/commit/d3b3e87a2d39992d1da291f552869f1…
Author: Henning Westerholt <hw(a)kamailio.org>
Committer: Henning Westerholt <hw(a)kamailio.org>
Date: 2018-12-29T01:50:19+01:00
core: refactor PKG, SHM, and SYS* memory allocation error logging helper #defines
- refactor PKG, SHM, and SYS* memory allocation error logging helper #defines
- replace *_SZ and *_MSG by *_FTM #defines, which accept variable parameters
- usage example: PKG_MEM_ERROR_FMT("for the record index %d\n", i);
- output: "could not allocate private memory from pkg pool - for the record index 2"
- because of the variable parameters you need to add a '\n' at the end
---
Modified: src/core/mem/pkg.h
Modified: src/core/mem/shm.h
---
Diff: https://github.com/kamailio/kamailio/commit/d3b3e87a2d39992d1da291f552869f1…
Patch: https://github.com/kamailio/kamailio/commit/d3b3e87a2d39992d1da291f552869f1…