From fc52a54370c085d6fa951da876eee99580677922 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 3 May 2024 14:57:47 +0200 Subject: [PATCH] core: parser/contact - basic validation tests for contact uri --- src/core/parser/contact/contact.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/core/parser/contact/contact.c b/src/core/parser/contact/contact.c index 322a22e9590..c67fe681d51 100644 --- a/src/core/parser/contact/contact.c +++ b/src/core/parser/contact/contact.c @@ -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)); @@ -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;