diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-30 13:33:46 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-30 13:33:46 +0100 |
commit | d3fbcd122012af7733de3b80a692f79ad69057b2 (patch) | |
tree | d7072386978c9f1e70cd7119643c24fd087d69e0 | |
parent | d9528c265b96a5a0f0c2e43ac74ab3921a2987e1 (diff) | |
download | monitoring-plugins-d3fbcd122012af7733de3b80a692f79ad69057b2.tar.gz |
check_http: Add space for ending NULL byte in array for chunked encoding
-rw-r--r-- | plugins/check_http.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index c23625e9..5fa310f5 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -1438,7 +1438,8 @@ char *unchunk_content(const char *content) { | |||
1438 | overall_size += length_of_chunk; | 1438 | overall_size += length_of_chunk; |
1439 | 1439 | ||
1440 | if (result == NULL) { | 1440 | if (result == NULL) { |
1441 | result = (char *)calloc(length_of_chunk, sizeof(char)); | 1441 | // Size of the chunk plus the ending NULL byte |
1442 | result = (char *)malloc(length_of_chunk +1); | ||
1442 | if (result == NULL) { | 1443 | if (result == NULL) { |
1443 | if (verbose) { | 1444 | if (verbose) { |
1444 | printf("Failed to allocate memory for unchunked body\n"); | 1445 | printf("Failed to allocate memory for unchunked body\n"); |
@@ -1446,7 +1447,8 @@ char *unchunk_content(const char *content) { | |||
1446 | return NULL; | 1447 | return NULL; |
1447 | } | 1448 | } |
1448 | } else { | 1449 | } else { |
1449 | void *tmp = realloc(result, overall_size); | 1450 | // Enlarge memory to the new size plus the ending NULL byte |
1451 | void *tmp = realloc(result, overall_size +1); | ||
1450 | if (tmp == NULL) { | 1452 | if (tmp == NULL) { |
1451 | if (verbose) { | 1453 | if (verbose) { |
1452 | printf("Failed to allocate memory for unchunked body\n"); | 1454 | printf("Failed to allocate memory for unchunked body\n"); |