Description: fix check_http - was having constant socket timeouts

  [Backport]
  Only the realloc() logic for the my_recv() buffer was backported.
  It made signifiant performance improvements and was worth to be
  backported.

Author: Bryan Heden <bheden@nagios.com>
Origin: backport, https://github.com/nagios-plugins/nagios-plugins/commit/2b38350d54
Bug-Ubuntu: https://launchpad.net/bugs/1875517
Reviewed-By: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
Last-Update: 2020-05-02

--- monitoring-plugins-2.2.orig/plugins/check_http.c
+++ monitoring-plugins-2.2/plugins/check_http.c
@@ -1046,8 +1046,11 @@ 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;
 
