Module: kamailio
Branch: 5.7
Commit: 45fd99f53643b56bce65eb9d603a5b81059aa21d
URL:
https://github.com/kamailio/kamailio/commit/45fd99f53643b56bce65eb9d603a5b8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-05-07T17:31:21+02:00
core: parser/contact - basic validation tests for contact uri
(cherry picked from commit fc52a54370c085d6fa951da876eee99580677922)
(cherry picked from commit d75dba611808322356fc8d1ebc9f8c30b4124a15)
---
Modified: src/core/parser/contact/contact.c
---
Diff:
https://github.com/kamailio/kamailio/commit/45fd99f53643b56bce65eb9d603a5b8…
Patch:
https://github.com/kamailio/kamailio/commit/45fd99f53643b56bce65eb9d603a5b8…
---
diff --git a/src/core/parser/contact/contact.c b/src/core/parser/contact/contact.c
index 56a37af1785..caf2e38d904 100644
--- a/src/core/parser/contact/contact.c
+++ b/src/core/parser/contact/contact.c
@@ -220,10 +220,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));
@@ -265,6 +267,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;