]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11987: [sofia-sip] Extract URI from info param of SIP Identity Header
authorAndrey Volk <andywolk@gmail.com>
Fri, 9 Aug 2019 09:39:44 +0000 (13:39 +0400)
committerAndrey Volk <andywolk@gmail.com>
Tue, 13 Aug 2019 15:53:11 +0000 (19:53 +0400)
- 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

libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/sip/sip_basic.c

index 9c8dbe86549bfaecbf500057211f652f68563bc6..cd3d3611fca9ed51e4e716f7208935a10c290c2b 100644 (file)
@@ -1 +1 @@
-Thu Aug  8 15:09:57 CDT 2019
+Tue Aug 13 10:50:57 CDT 2019
index 85f4aa2328fd813b121949457567377114427519..0dc57fd680f42c60ee5de86af773a720b8bbe446 100644 (file)
@@ -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)
 {
   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;
 
   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=");
   if (p) {
-         ib = p + 5;
+
          ie = strchr(p, ';');
          pp = strchr(p, '<');
+         ppp = strchr(p, '>');
 
-         if (!ie) return 0;
-
-         if (pp && pp < ie) {
+         // 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)) {
 
-                 // info= with opening '<'
-                 // must contain closing '>' before ';'
-                 ppp = strchr(pp, '>');
-                 if (!ppp || ppp > ie) {
-                         return 0;
-                 } else {
-                         ib = pp + 1;
-                         ie = ppp - 1;
+                 len = ppp - pp;
+                 if ((result = malloc(len))) {
+                         memcpy(result, pp + 1, len - 1);
+                         result[len - 1] = '\0';
+                         id->id_info = result;
                  }
          }
-
-         len = ie - ib + 1;
-         id->id_info = strndup(ib, len);
   }
 
   return 0;