Bladeren bron

Fix memory leak in check_http for large pages (Jimmy Bergman - #2957455)

Ton Voon 16 jaren geleden
bovenliggende
commit
6b782ebfd4
3 gewijzigde bestanden met toevoegingen van 6 en 1 verwijderingen
  1. 1 0
      NEWS
  2. 1 0
      THANKS.in
  3. 4 1
      plugins/check_http.c

+ 1 - 0
NEWS

@@ -8,6 +8,7 @@ This file documents the major additions and syntax changes between releases.
 	check_icmp now increment the sequence counter in each packet
 	check_icmp now increment the sequence counter in each packet
 	Fix usage of repeated -o options in check_snmp
 	Fix usage of repeated -o options in check_snmp
 	Try to detect arguments passed via --with-ping[6]-command and set options accordingly (#2908236)
 	Try to detect arguments passed via --with-ping[6]-command and set options accordingly (#2908236)
+	Fix memory leak in check_http for large pages (Jimmy Bergman - #2957455)
 	WARNINGS
 	WARNINGS
 	Updated developer documentation to say that performance labels should not have an equals sign or
 	Updated developer documentation to say that performance labels should not have an equals sign or
 	single quote in the label
 	single quote in the label

+ 1 - 0
THANKS.in

@@ -258,3 +258,4 @@ Nikita Kalabukhov
 Grant Byers
 Grant Byers
 Marcel Kuiper
 Marcel Kuiper
 Bryan Irvine
 Bryan Irvine
+Jimmy Bergman

+ 4 - 1
plugins/check_http.c

@@ -784,6 +784,7 @@ check_http (void)
   int i = 0;
   int i = 0;
   size_t pagesize = 0;
   size_t pagesize = 0;
   char *full_page;
   char *full_page;
+  char *full_page_new;
   char *buf;
   char *buf;
   char *pos;
   char *pos;
   long microsec;
   long microsec;
@@ -871,7 +872,9 @@ check_http (void)
   full_page = strdup("");
   full_page = strdup("");
   while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) {
   while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) {
     buffer[i] = '\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;
     pagesize += i;
 
 
                 if (no_body && document_headers_done (full_page)) {
                 if (no_body && document_headers_done (full_page)) {