From f95110eb9993861e450567a64dcfc46ab4000e20 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Tue, 27 Dec 2022 18:04:16 +0000 Subject: [PATCH] Adding d/p/21_check_http_faster_with_large_files from upstream --- .../21_check_http_faster_with_large_files | 37 +++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 38 insertions(+) create mode 100644 debian/patches/21_check_http_faster_with_large_files diff --git a/debian/patches/21_check_http_faster_with_large_files b/debian/patches/21_check_http_faster_with_large_files new file mode 100644 index 0000000..06a63d8 --- /dev/null +++ b/debian/patches/21_check_http_faster_with_large_files @@ -0,0 +1,37 @@ +From 763862a61cf5a7ba1a10f607022aac2434c79f57 Mon Sep 17 00:00:00 2001 +From: Danijel Tasov +Date: Wed, 21 Dec 2022 14:48:11 +0100 +Subject: [PATCH] make check_http faster with larger files + +The current implementation becomes exponentially slower with growing +response size. + +See also: + +https://github.com/nagios-plugins/nagios-plugins/blob/release-2.4.2/plugins/check_http.c#L1199-L1204 + +--- + plugins/check_http.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/plugins/check_http.c b/plugins/check_http.c +index 41d478163..1835a2d09 100644 +--- a/plugins/check_http.c ++++ b/plugins/check_http.c +@@ -1095,9 +1095,14 @@ check_http (void) + *pos = ' '; + } + buffer[i] = '\0'; +- xasprintf (&full_page_new, "%s%s", full_page, buffer); +- free (full_page); ++ ++ if ((full_page_new = realloc(full_page, pagesize + i + 1)) == NULL) ++ die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate memory for full_page\n")); ++ ++ memmove(&full_page_new[pagesize], buffer, i + 1); ++ + full_page = full_page_new; ++ + pagesize += i; + + if (no_body && document_headers_done (full_page)) { diff --git a/debian/patches/series b/debian/patches/series index ad3b0d3..f34d942 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -9,3 +9,4 @@ 18_check_icmp_help 19_check_disk_fs_usage 20_check_apt_unknown_escape_sequence +21_check_http_faster_with_large_files