Browse Source

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
Richard Fuchs 1 month ago
parent
commit
6281f71476
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/modules/rtpengine/rtpengine.c

+ 3 - 2
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;
 }