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

Author: Richard Fuchs <rfu...@sipwise.com>
Committer: Richard Fuchs <rfu...@sipwise.com>
Date: 2025-08-06T08:03:18-04:00

rtpengine: enlarge cookie buffer

With `server_id` being a signed int, it may be negative, taking up 11
characters instead of 10.

Add explicit type casts to ensure future consistency.

Closes #4350

---

Modified: src/modules/rtpengine/rtpengine.c

---

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

---

diff --git a/src/modules/rtpengine/rtpengine.c 
b/src/modules/rtpengine/rtpengine.c
index 0207d913116..8f32a0d04cd 100644
--- a/src/modules/rtpengine/rtpengine.c
+++ b/src/modules/rtpengine/rtpengine.c
@@ -3178,9 +3178,10 @@ static void mod_destroy(void)
 
 static char *gencookie(void)
 {
-       static char cook[34];
+       static char cook[35]; // 11 + 1 + 10 + 1 + 10 + 1 + 1
 
-       snprintf(cook, 34, "%d_%u_%u ", server_id, fastrand(), myseqn);
+       snprintf(cook, 35, "%" PRId32 "_%" PRIu32 "_%" PRIu32 " ",
+                       (int32_t) server_id, (uint32_t) fastrand(), (uint32_t) 
myseqn);
        myseqn++;
        return cook;
 }

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to