Skip to content

Commit

Permalink
core: parse - validity check for contact uri size and more verbose lo…
Browse files Browse the repository at this point in the history
…g message

(cherry picked from commit 69f9b0a)
  • Loading branch information
miconda authored and henningw committed Apr 11, 2019
1 parent c7a172c commit 45ac770
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/parser/contact/contact.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 45ac770

Please sign in to comment.