Module: kamailio
Branch: master
Commit: 3c07e2351a94e4ff2cf3c6b9b9df4d7462cd5760
URL:
https://github.com/kamailio/kamailio/commit/3c07e2351a94e4ff2cf3c6b9b9df4d7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-06-18T16:25:25+02:00
pdb: safety check for header length in pdb_msg_dbg()
---
Modified: src/modules/pdb/pdb.c
---
Diff:
https://github.com/kamailio/kamailio/commit/3c07e2351a94e4ff2cf3c6b9b9df4d7…
Patch:
https://github.com/kamailio/kamailio/commit/3c07e2351a94e4ff2cf3c6b9b9df4d7…
---
diff --git a/src/modules/pdb/pdb.c b/src/modules/pdb/pdb.c
index eb59656734..b72ecf7f29 100644
--- a/src/modules/pdb/pdb.c
+++ b/src/modules/pdb/pdb.c
@@ -148,9 +148,13 @@ static void pdb_msg_dbg(struct pdb_msg msg, char *dbg_msg) {
char buf[PAYLOADSIZE * 3 + 1];
char *ptr = buf;
- for (i = 0; i < msg.hdr.length - sizeof(msg.hdr); i++) {
- ptr += sprintf(ptr,"%02X ", msg.bdy.payload[i]);
- }
+ if(msg.hdr.length > sizeof(msg.hdr)) {
+ for (i = 0; i < msg.hdr.length - sizeof(msg.hdr); i++) {
+ ptr += sprintf(ptr, "%02X ", msg.bdy.payload[i]);
+ }
+ } else {
+ *ptr = '\0';
+ }
LM_DBG("%s\n"
"version = %d\ntype = %d\ncode = %d\nid = %d\nlen = %d\n"