提交 6fe1a87e authored 作者: Andrey Volk's avatar Andrey Volk

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
上级 c57d7704
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); ...@@ -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) ...@@ -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 (pp && pp < ie) { if (ie && pp && ppp && (pp < ppp) && (ppp < ie)) {
// info= with opening '<' len = ppp - pp;
// must contain closing '>' before ';' if ((result = malloc(len))) {
ppp = strchr(pp, '>'); memcpy(result, pp + 1, len - 1);
if (!ppp || ppp > ie) { result[len - 1] = '\0';
return 0; id->id_info = result;
} else {
ib = pp + 1;
ie = ppp - 1;
} }
} }
len = ie - ib + 1;
id->id_info = strndup(ib, len);
} }
return 0; return 0;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论