Module: monitoring-plugins
Branch: fix_1829
Commit: d3fbcd122012af7733de3b80a692f79ad69057b2
Author: Lorenz Kästle <[email protected]>
Date: Mon Jan 30 13:33:46 2023 +0100
URL:
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=d3fbcd1
check_http: Add space for ending NULL byte in array for chunked encoding
---
plugins/check_http.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/plugins/check_http.c b/plugins/check_http.c
index c23625e..5fa310f 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1438,7 +1438,8 @@ char *unchunk_content(const char *content) {
overall_size += length_of_chunk;
if (result == NULL) {
- result = (char *)calloc(length_of_chunk, sizeof(char));
+ // Size of the chunk plus the ending NULL byte
+ result = (char *)malloc(length_of_chunk +1);
if (result == NULL) {
if (verbose) {
printf("Failed to allocate memory for unchunked body\n");
@@ -1446,7 +1447,8 @@ char *unchunk_content(const char *content) {
return NULL;
}
} else {
- void *tmp = realloc(result, overall_size);
+ // Enlarge memory to the new size plus the ending NULL byte
+ void *tmp = realloc(result, overall_size +1);
if (tmp == NULL) {
if (verbose) {
printf("Failed to allocate memory for unchunked body\n");