Code

Fixed coredump with unallocated string
authorTon Voon <tonvoon@users.sourceforge.net>
Fri, 21 Feb 2003 21:59:17 +0000 (21:59 +0000)
committerTon Voon <tonvoon@users.sourceforge.net>
Fri, 21 Feb 2003 21:59:17 +0000 (21:59 +0000)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@351 f882894a-f735-0410-b71e-b25c423dba1c

plugins/check_http.c

index 8ffbf989bef7df3b08e012c40f69c9e42bd2cebc..856acdea6e8bb7d532e859346e6abf174bbfc271 100644 (file)
@@ -203,8 +203,8 @@ char server_port_text[6] = "";
 char server_type[6] = "http";
 char *server_address = ""; 
 char *host_name = "";
-char *server_url = HTTP_URL;
-int server_url_length = 1;
+char *server_url = "";
+int server_url_length;
 int server_expect_yn = 0;
 char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
 char string_expect[MAX_INPUT_BUFFER] = "";
@@ -235,6 +235,10 @@ main (int argc, char **argv)
 {
        int result = STATE_UNKNOWN;
 
+       /* Set default URL. Must be malloced for subsequent realloc if --onredirect=follow */
+       asprintf (&server_url, "%s", HTTP_URL);
+       server_url_length = strlen(server_url);
+
        if (process_arguments (argc, argv) == ERROR)
                usage ("check_http: could not parse arguments\n");