summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-02-06 10:39:44 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-02-06 10:39:44 (GMT)
commit6d3e44d2d8395076060e9c741e9b173dc5d57b76 (patch)
tree2c0a60b8276f706d440d5dca80d66affa9b1c765 /plugins
parentfc8a233854c0d59cf637e982b84c836920d718bd (diff)
downloadmonitoring-plugins-6d3e44d2d8395076060e9c741e9b173dc5d57b76.tar.gz
check_http: Handle chunked encoding without actual content correctly
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_http.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 5fa310f..8dda046 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1462,7 +1462,13 @@ char *unchunk_content(const char *content) {
1462 memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk); 1462 memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk);
1463 } 1463 }
1464 1464
1465 result[overall_size] = '\0'; 1465 if (overall_size == 0 && result == NULL) {
1466 // We might just have received the end chunk without previous content, so result is never allocated
1467 result = calloc(1, sizeof(char));
1468 // No error handling here, we can only return NULL anyway
1469 } else {
1470 result[overall_size] = '\0';
1471 }
1466 return result; 1472 return result;
1467} 1473}
1468 1474