[sr-dev] git:master:dbf9b284: ims_diameter_server: 0-terminate value converted to json

Daniel-Constantin Mierla miconda at gmail.com
Fri Apr 22 13:21:55 CEST 2022


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-04-22T12:29:35+02:00

ims_diameter_server: 0-terminate value converted to json

---

Modified: src/modules/ims_diameter_server/avp_helper.c

---

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

---

diff --git a/src/modules/ims_diameter_server/avp_helper.c b/src/modules/ims_diameter_server/avp_helper.c
index 04e2d6d967..73c0e047ea 100644
--- a/src/modules/ims_diameter_server/avp_helper.c
+++ b/src/modules/ims_diameter_server/avp_helper.c
@@ -164,9 +164,10 @@ int AAAmsg2json(AAAMessage * request, str * dest) {
 	}
 
 	dest->len = strlen(out);
-	dest->s = pkg_malloc(dest->len);
+	dest->s = pkg_malloc(dest->len + 1);
 	if (dest->s) {
 		memcpy(dest->s, out, dest->len);
+		dest->s[dest->len] = '\0';
 		free(out);
 	} else {
 		LM_WARN("Failed to allocate %d bytes for the JSON\n", dest->len);




More information about the sr-dev mailing list