https://bugs.gentoo.org/893252 https://github.com/monitoring-plugins/monitoring-plugins/issues/1836 https://github.com/monitoring-plugins/monitoring-plugins/commit/6d3e44d2d8395076060e9c741e9b173dc5d57b76 diff --git a/plugins/check_http.c b/plugins/check_http.c index 5fa310f5d..8dda046ff 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1462,7 +1462,13 @@ char *unchunk_content(const char *content) { memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk); } - result[overall_size] = '\0'; + if (overall_size == 0 && result == NULL) { + // We might just have received the end chunk without previous content, so result is never allocated + result = calloc(1, sizeof(char)); + // No error handling here, we can only return NULL anyway + } else { + result[overall_size] = '\0'; + } return result; }