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

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

core: strutils - check end for hex escape in urlencode()

---

Modified: src/core/strutils.c

---

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

---

diff --git a/src/core/strutils.c b/src/core/strutils.c
index 154dc08a866..431b9d3c8fd 100644
--- a/src/core/strutils.c
+++ b/src/core/strutils.c
@@ -903,13 +903,15 @@ int urlencode(str *sin, str *sout)
 int urldecode(str *sin, str *sout)
 {
        char *at, *p;
+       char *end;
 
        at = sout->s;
        p = sin->s;
+       end = sin->s + sin->len;
 
-       while(p < sin->s + sin->len) {
+       while(p < end) {
                if(*p == '%') {
-                       if(p[1] && p[2]) {
+                       if(p + 2 < end) {
                                *at++ = hex_to_char(p[1]) << 4 | 
hex_to_char(p[2]);
                                p += 2;
                        }

_______________________________________________
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