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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-05-03T20:55:15+02:00

core: cast to unsigned for shifting in digest parser

---

Modified: src/core/parser/digest/param_parser.c

---

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

---

diff --git a/src/core/parser/digest/param_parser.c 
b/src/core/parser/digest/param_parser.c
index 91411f3222f..aa8febb6a48 100644
--- a/src/core/parser/digest/param_parser.c
+++ b/src/core/parser/digest/param_parser.c
@@ -30,8 +30,8 @@
 #include "../../trim.h"
 #include "../../ut.h"
 
-#define LOWER_BYTE(b) ((b) | 0x20)
-#define LOWER_DWORD(d) ((d) | 0x20202020)
+#define LOWER_BYTE(b) (((unsigned char)(b)) | 0x20)
+#define LOWER_DWORD(d) ((d) | 0x20202020U)
 
 /*
  * Parse short (less than 4 bytes) parameter names
@@ -74,8 +74,11 @@
  * does not allow reading 4-bytes at once from unaligned memory position
  * (Sparc for example)
  */
-#define READ(val) \
-       (*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16) + (*(val + 3) << 
24))
+#define READ(val)                                                 \
+       (((unsigned int)(unsigned char)*((val) + 0))                  \
+                       + (((unsigned int)(unsigned char)*((val) + 1)) << 8)  \
+                       + (((unsigned int)(unsigned char)*((val) + 2)) << 16) \
+                       + (((unsigned int)(unsigned char)*((val) + 3)) << 24))
 
 
 #define name_CASE                  \
@@ -194,7 +197,7 @@
 int parse_param_name(str *_s, dig_par_t *_type)
 {
        register char *p;
-       register int val;
+       register unsigned int val;
        char *end;
 
        end = _s->s + _s->len;

_______________________________________________
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