mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-09 01:06:00 +00:00
FS-11987: [sofia-sip] Extract URI from info param of SIP Identity Header
- allow for a spaces between "info=" and opening '<' - extract URI from inside "<>" but allow empty - let the higher level app decide what to do about it - replace strndup (does not exist on Windows) with memcpy
This commit is contained in:
parent
c57d7704d1
commit
6fe1a87e3e
@ -1 +1 @@
|
|||||||
Thu Aug 8 15:09:57 CDT 2019
|
Tue Aug 13 10:50:57 CDT 2019
|
||||||
|
@ -2849,7 +2849,8 @@ SIP_HEADER_CLASS(identity, "Identity", "", id_common, single, identity);
|
|||||||
issize_t sip_identity_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen)
|
issize_t sip_identity_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen)
|
||||||
{
|
{
|
||||||
sip_identity_t *id = (sip_identity_t *)h;
|
sip_identity_t *id = (sip_identity_t *)h;
|
||||||
char const *p = NULL, *pp = NULL, *ppp = NULL, *ib = NULL, *ie = NULL;
|
char const *p = NULL, *pp = NULL, *ppp = NULL, *ie = NULL;
|
||||||
|
char *result = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
id->id_value = strdup(s);
|
id->id_value = strdup(s);
|
||||||
@ -2857,27 +2858,22 @@ issize_t sip_identity_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen)
|
|||||||
|
|
||||||
p = strstr(s, "info=");
|
p = strstr(s, "info=");
|
||||||
if (p) {
|
if (p) {
|
||||||
ib = p + 5;
|
|
||||||
ie = strchr(p, ';');
|
ie = strchr(p, ';');
|
||||||
pp = strchr(p, '<');
|
pp = strchr(p, '<');
|
||||||
|
ppp = strchr(p, '>');
|
||||||
|
|
||||||
if (!ie) return 0;
|
// allow for a spaces between "info=" and opening '<'
|
||||||
|
// extract URI from inside "<>" but allow empty - let the higher level app decide what to do about it
|
||||||
|
if (ie && pp && ppp && (pp < ppp) && (ppp < ie)) {
|
||||||
|
|
||||||
if (pp && pp < ie) {
|
len = ppp - pp;
|
||||||
|
if ((result = malloc(len))) {
|
||||||
// info= with opening '<'
|
memcpy(result, pp + 1, len - 1);
|
||||||
// must contain closing '>' before ';'
|
result[len - 1] = '\0';
|
||||||
ppp = strchr(pp, '>');
|
id->id_info = result;
|
||||||
if (!ppp || ppp > ie) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
ib = pp + 1;
|
|
||||||
ie = ppp - 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len = ie - ib + 1;
|
|
||||||
id->id_info = strndup(ib, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user