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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-05-02T19:34:16+02:00

core: strutils - check position at escape sequence for unescape_user()

---

Modified: src/core/strutils.c

---

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

---

diff --git a/src/core/strutils.c b/src/core/strutils.c
index e6d60f74ba3..f3c890cf4a2 100644
--- a/src/core/strutils.c
+++ b/src/core/strutils.c
@@ -187,6 +187,10 @@ int unescape_user(str *sin, str *sout)
        while(p < sin->s + sin->len) {
                if(*p == '%') {
                        p++;
+                       if(p >= sin->s + sin->len) {
+                               LM_ERR("incomplete escaped sequence at end of 
string\n");
+                               return -1;
+                       }
                        switch(*p) {
                                case '0':
                                case '1':
@@ -221,6 +225,10 @@ int unescape_user(str *sin, str *sout)
                                        return -1;
                        }
                        p++;
+                       if(p >= sin->s + sin->len) {
+                               LM_ERR("incomplete escaped sequence at end of 
string\n");
+                               return -1;
+                       }
                        switch(*p) {
                                case '0':
                                case '1':

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to