Hi,
I was trying to use registered("location", "$ru", 0, 1)
Last parameter is the flag according to
http://kamailio.org/docs/modules/stable/modules/registrar.html#registrar.f.…
flag values is as follows:
1 - set xavp_rcd with value from matched contact
But I'm getting NULL instead of ruid.. While the same works after
lookup("location").
So I took a quick look into the code and that confirms that registered4
does not add the xavp with details of the record (ruid), i.e. it does
not do what the lookup_helper does.
Is this done on purpose or an oversight? While fixing this it might be
reasonable to introduce a new function for setting the XAVPs and call it
from lookup and registered4 functions, especially since we are going to
extend the attributes list beyond just ruid, but right now I'm
struggling just to understanding how the XAVP should be built.. Ideas?
Thanks,
Andrew
Module: kamailio
Branch: master
Commit: c078256b927ae4b30ba9e5ae9595e5b2084dcdb6
URL: https://github.com/kamailio/kamailio/commit/c078256b927ae4b30ba9e5ae9595e5b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-09-03T11:32:10+02:00
Merge pull request #313 from vance-od/patch-1
auth: fixed issue when during registration nonce expired, after backwards time shift
---
Modified: modules/auth/nonce.c
---
Diff: https://github.com/kamailio/kamailio/commit/c078256b927ae4b30ba9e5ae9595e5b…
Patch: https://github.com/kamailio/kamailio/commit/c078256b927ae4b30ba9e5ae9595e5b…
---
diff --git a/modules/auth/nonce.c b/modules/auth/nonce.c
index 95b967e..025d0d7 100644
--- a/modules/auth/nonce.c
+++ b/modules/auth/nonce.c
@@ -357,7 +357,13 @@ int check_nonce(auth_body_t* auth, str* secret1, str* secret2,
different length (for example because of different auth.
checks).. Therefore we force credentials to be rebuilt by UAC
without prompting for password */
- return 4;
+ /* if current time is less than start time, reset the start time
+ (e.g., after start, the system clock was set in the past) */
+ t=time(0);
+ if (t < up_since)
+ up_since = t;
+ if (since < t)
+ return 4;
}
t=time(0);
if (unlikely((since > t) && ((since-t) > nonce_auth_max_drift) )){
Module: kamailio
Branch: master
Commit: 063e32a8fe81b2cfbaac0386e6b51446586e619a
URL: https://github.com/kamailio/kamailio/commit/063e32a8fe81b2cfbaac0386e6b5144…
Author: vance-od <vance(a)ukr.net>
Committer: vance-od <vance(a)ukr.net>
Date: 2015-09-03T11:43:37+03:00
Update nonce.c
auth: fixed issue when during registration nonce expired, after backwards time shift
---
Modified: modules/auth/nonce.c
---
Diff: https://github.com/kamailio/kamailio/commit/063e32a8fe81b2cfbaac0386e6b5144…
Patch: https://github.com/kamailio/kamailio/commit/063e32a8fe81b2cfbaac0386e6b5144…
---
diff --git a/modules/auth/nonce.c b/modules/auth/nonce.c
index 95b967e..025d0d7 100644
--- a/modules/auth/nonce.c
+++ b/modules/auth/nonce.c
@@ -357,7 +357,13 @@ int check_nonce(auth_body_t* auth, str* secret1, str* secret2,
different length (for example because of different auth.
checks).. Therefore we force credentials to be rebuilt by UAC
without prompting for password */
- return 4;
+ /* if current time is less than start time, reset the start time
+ (e.g., after start, the system clock was set in the past) */
+ t=time(0);
+ if (t < up_since)
+ up_since = t;
+ if (since < t)
+ return 4;
}
t=time(0);
if (unlikely((since > t) && ((since-t) > nonce_auth_max_drift) )){
Fix buffer overflow in READ call by making a SAFE_READ that checks
the actual length of the buffer.
In the buffer overflow case parse_hname2 is called with 'begin' set to
the string "Reason:". This string was originally allocated in in
rval_get_str as length 6, contents "Reason\0'. The actual pkg_malloc
is size of 7 to account for the null terminator.
In the caller to parse_hname2 (modules/textops/textops.c line 2229)
the null terminator is replaced with a ':' character.
parse_hname2 hits the FIRST_QUARTERNIONS macro which expands to a
bunch of case statements. The one for the Reason string looks like
(macro expanded):
case _reas_:
p += 4;
val = READ(p);
switch(LOWER_DWORD(val)) {
case _on1_:
hdr->type = HDR_REASON_T;
hdr->name.len = 6;
return (p + 3);
The overflow occurs in the READ call. READ is:
(*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16) + (*(val + 3) << 24))
With 'p' pointing to "Reason:", then p+4 is "on:". That's only three
characters of allocated memory left(the : was originally the null
character as explained above and the total pkg_malloc allocated length
was 7). READ accesses 4 bytes so we go one past the end of the
allocated area.
The error is noticeable in a DBG_SYS_MALLOC build but not a PKG_MALLOC
build - I assume the latter has a large arena allocated making the
buffer overflow still valid memory.
There are likely other buffer overflows in the READ usage in other cases in this function. I've [posted to the mailing list](http://lists.sip-router.org/pipermail/sr-dev/2015-August/030529.html) about the issue and whether a more general fix is possible:
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/308
-- Commit Summary --
* Fix read buffer overflow in parse_hname2
-- File Changes --
M parser/case_reas.h (2)
M parser/parse_hname2.c (19)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/308.patchhttps://github.com/kamailio/kamailio/pull/308.diff
---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/308