Module: kamailio
Branch: master
Commit: 69f9b0a4d5261ec5b6d8d7163b3809a9bb24916d
URL: 
https://github.com/kamailio/kamailio/commit/69f9b0a4d5261ec5b6d8d7163b3809a9bb24916d

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2019-04-11T09:38:49+02:00

core: parse - validity check for contact uri size and more verbose log message

---

Modified: src/core/parser/contact/contact.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/69f9b0a4d5261ec5b6d8d7163b3809a9bb24916d.diff
Patch: 
https://github.com/kamailio/kamailio/commit/69f9b0a4d5261ec5b6d8d7163b3809a9bb24916d.patch

---

diff --git a/src/core/parser/contact/contact.c 
b/src/core/parser/contact/contact.c
index 61a40e3bd8..650740b1a1 100644
--- a/src/core/parser/contact/contact.c
+++ b/src/core/parser/contact/contact.c
@@ -182,6 +182,9 @@ int parse_contacts(str* _s, contact_t** _c)
 {
        contact_t* c;
        param_hooks_t hooks;
+       str sv;
+
+       sv = *_s;
 
        while(1) {
                /* Allocate and clear contact structure */
@@ -220,6 +223,10 @@ int parse_contacts(str* _s, contact_t** _c)
                }
 
                trim(&c->uri);
+               if((c->uri.len <= 0) || (c->uri.s + c->uri.len > sv.s + 
sv.len)) {
+                       LM_ERR("invlid contact uri\n");
+                       goto error;
+               }
 
                if (_s->len == 0) goto ok;
 
@@ -265,6 +272,8 @@ int parse_contacts(str* _s, contact_t** _c)
        }
 
 error:
+       LM_ERR("failure parsing '%.*s' (%d) [%p/%p/%d]\n", sv.len, sv.s, sv.len,
+                       sv.s, _s->s, (int)(_s->s - sv.s));
        if (c) pkg_free(c);
        free_contacts(_c); /* Free any contacts created so far */
        return -1;


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to