Code

Fix for check_ping old-style argument handling (Patrick McCormick - 892211)
authorTon Voon <tonvoon@users.sourceforge.net>
Mon, 9 Feb 2004 08:27:54 +0000 (08:27 +0000)
committerTon Voon <tonvoon@users.sourceforge.net>
Mon, 9 Feb 2004 08:27:54 +0000 (08:27 +0000)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@799 f882894a-f735-0410-b71e-b25c423dba1c

plugins/check_ping.c

index ab5e0cc327271d57446e703a0e9be96b7c869798..1d34656cf6a79145f5d15d7317ac90c96cc919d4 100644 (file)
@@ -74,7 +74,8 @@ main (int argc, char **argv)
        bindtextdomain (PACKAGE, LOCALEDIR);
        textdomain (PACKAGE);
 
-       addresses = malloc ((size_t)max_addr);
+       addresses = malloc (sizeof(char*) * max_addr);
+       addresses[0] = NULL;
 
        if (process_arguments (argc, argv) == ERROR)
                usage (_("Could not parse arguments"));
@@ -228,7 +229,7 @@ process_arguments (int argc, char **argv)
                                n_addresses++;
                                if (n_addresses > max_addr) {
                                        max_addr *= 2;
-                                       addresses = realloc (addresses, (size_t)max_addr);
+                                       addresses = realloc (addresses, sizeof(char*) * max_addr);
                                        if (addresses == NULL)
                                                die (STATE_UNKNOWN, _("Could not realloc() addresses\n"));
                                }
@@ -272,6 +273,7 @@ process_arguments (int argc, char **argv)
                        return ERROR;
                } else {
                        addresses[0] = argv[c++];
+                       n_addresses++;
                        if (c == argc)
                                return validate_arguments ();
                }