Skip to content

Commit

Permalink
core: parser/contact - basic validation tests for contact uri
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed May 3, 2024
1 parent d6b0beb commit fc52a54
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/core/parser/contact/contact.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,12 @@ int parse_contacts(str *_s, contact_t **_c)
param_hooks_t hooks;
str sv;
int n;
int star;

sv = *_s;

n = 0;
star = 0;
while(1) {
/* Allocate and clear contact structure */
c = (contact_t *)pkg_malloc(sizeof(contact_t));
Expand Down Expand Up @@ -277,6 +279,25 @@ int parse_contacts(str *_s, contact_t **_c)
LM_ERR("invalid contact uri\n");
goto error;
}
if(c->uri.len == 1) {
if(c->uri.s[0] == '*') {
if(star == 1) {
LM_ERR("too many star contacts - index %d\n", n);
goto error;
} else {
star = 1;
}
} else {
LM_ERR("contact uri size 1 is too short - index %d\n", n);
goto error;
}
} else if(c->uri.len < 3) {
/* minimum length 's:a' (s - schema; a - address) */
LM_ERR("contact uri size %d is too short - index %d\n", n,
c->uri.len);
goto error;
}

if(_s->len == 0)
goto ok;

Expand Down

0 comments on commit fc52a54

Please sign in to comment.