check_http: add fix for large files

This commit is contained in:
Jan Wagner 2010-03-03 08:14:36 +00:00
parent d386a80069
commit 507277ff4c
3 changed files with 45 additions and 1 deletions

4
debian/changelog vendored
View file

@ -4,8 +4,10 @@ nagios-plugins (1.4.14-2) UNRELEASED; urgency=low
* Add some hints to NEWS.Debian about the use on non-linux archs
* Bump Standards-Version to 3.8.4, no changes needed
* Add 1.0 to debian/source/format
* Add 43_check_http_large_pages_mleak.dpatch, taken from upstream, which
fixes memory leaks on large files
-- Jan Wagner <waja@cyconet.org> Sat, 23 Jan 2010 01:39:31 +0100
-- Jan Wagner <waja@cyconet.org> Wed, 03 Mar 2010 08:13:31 +0100
nagios-plugins (1.4.14-1) unstable; urgency=low

View file

@ -18,3 +18,4 @@
40_check_http_proxy_auth.dpatch
41_check_ping_detect_args.dpatch
42_check_linux_raid_fix_r10.dpatch
43_check_http_large_pages_mleak.dpatch

View file

@ -0,0 +1,41 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 43_check_http_large_pages_mleak.dpatch
## From: Ton Voon <ton.voon@opsera.com>
## Date: Fri, 26 Feb 2010 12:47:38 +0000
## Subject: [PATCH] Fix memory leak in check_http for large pages (Jimmy Bergman - #2957455)
## X-Git-Url: http://repo.or.cz/w/nagiosplugins.git?a=commitdiff_plain;h=6b782ebfd4832c1fe621556bcf894162b8caa8aa
##
## DP: Fix memory leak in check_http for large pages
@DPATCH@
---
plugins/check_http.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletions(-)
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 0a4b12b..5cdf144 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -784,6 +784,7 @@ check_http (void)
int i = 0;
size_t pagesize = 0;
char *full_page;
+ char *full_page_new;
char *buf;
char *pos;
long microsec;
@@ -871,7 +872,9 @@ check_http (void)
full_page = strdup("");
while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) {
buffer[i] = '\0';
- asprintf (&full_page, "%s%s", full_page, buffer);
+ asprintf (&full_page_new, "%s%s", full_page, buffer);
+ free (full_page);
+ full_page = full_page_new;
pagesize += i;
if (no_body && document_headers_done (full_page)) {
--
1.6.3