Module: kamailio
Branch: master
Commit: fc52a54370c085d6fa951da876eee99580677922
URL: 
https://github.com/kamailio/kamailio/commit/fc52a54370c085d6fa951da876eee99580677922

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2024-05-03T14:57:47+02:00

core: parser/contact - basic validation tests for contact uri

---

Modified: src/core/parser/contact/contact.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/fc52a54370c085d6fa951da876eee99580677922.diff
Patch: 
https://github.com/kamailio/kamailio/commit/fc52a54370c085d6fa951da876eee99580677922.patch

---

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;
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to