diff --git a/src/core/parser/contact/contact.c b/src/core/parser/contact/contact.c index 4c534ece77f..c87e3298647 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; @@ -264,6 +271,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;