Code

Fix an off-by-one error where a realloc(3) call doesn't allocate space
[nagiosplug.git] / plugins / check_http.c
index 5e33ec86113e485a55a24b1750e3ef6aea799bab..86e18dece070bf9fa95aabfc9ceaa6527a13d11a 100644 (file)
@@ -1101,7 +1101,7 @@ redir (char *pos, char *status_line)
     pos += i;
     pos += strspn (pos, " \t\r\n");
 
-    url = realloc (url, strcspn (pos, "\r\n"));
+    url = realloc (url, strcspn (pos, "\r\n") + 1);
     if (url == NULL)
       die (STATE_UNKNOWN, _("HTTP UNKNOWN - could not allocate url\n"));