Explorar o código

ims_diameter_server: 0-terminate value converted to json

Daniel-Constantin Mierla %!s(int64=3) %!d(string=hai) anos
pai
achega
dbf9b28402
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      src/modules/ims_diameter_server/avp_helper.c

+ 2 - 1
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);