Code

Don't try to print `optarg' (which will be a NULL pointer) if an unknown
authorHolger Weiss <hweiss@users.sourceforge.net>
Sun, 28 Jan 2007 21:46:41 +0000 (21:46 +0000)
committerHolger Weiss <hweiss@users.sourceforge.net>
Sun, 28 Jan 2007 21:46:41 +0000 (21:46 +0000)
command line option was used, as this leads to a segfault on some
systems.  The unknown option will be printed by getopt(3) anyway.  So,
simply call print_usage() and exit UNKNOWN via the new usage5() instead.

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1590 f882894a-f735-0410-b71e-b25c423dba1c

38 files changed:
plugins-root/check_dhcp.c
plugins/check_apt.c
plugins/check_by_ssh.c
plugins/check_dig.c
plugins/check_dns.c
plugins/check_fping.c
plugins/check_game.c
plugins/check_hpjd.c
plugins/check_http.c
plugins/check_ide_smart.c
plugins/check_ldap.c
plugins/check_load.c
plugins/check_mrtg.c
plugins/check_mrtgtraf.c
plugins/check_mysql.c
plugins/check_mysql_query.c
plugins/check_nagios.c
plugins/check_nt.c
plugins/check_ntp.c
plugins/check_nwstat.c
plugins/check_overcr.c
plugins/check_pgsql.c
plugins/check_ping.c
plugins/check_procs.c
plugins/check_radius.c
plugins/check_real.c
plugins/check_smtp.c
plugins/check_snmp.c
plugins/check_ssh.c
plugins/check_swap.c
plugins/check_tcp.c
plugins/check_time.c
plugins/check_ups.c
plugins/check_users.c
plugins/negate.c
plugins/urlize.c
plugins/utils.c
plugins/utils.h

index fbfb3311b2f4dc3b9270fe71a74c43a576b79036..245946b5ebd971c173f82ac2dc502f9ef70ff7d2 100644 (file)
@@ -1091,7 +1091,7 @@ int call_getopt(int argc, char **argv){
                        break;
 
                case '?': /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                        break;
 
                default:
index 902b455f7b3213d8289dfa628a7fc028d4ae2edb..f67ebf9be9ab4ac968c8098ed51a880df3047b34 100644 (file)
@@ -201,7 +201,7 @@ int process_arguments (int argc, char **argv) {
                        break;
                default:
                        /* print short usage statement if args not parsable */
-                       usage_va(_("Unknown argument - %s"), optarg);
+                       usage5();
                }
        }
 
index d1cbf936e91424ac3a8482e9d28a2046fc2fde4b..1675071c187e08cc5776ca160d8a8f72dbaeb119 100644 (file)
@@ -262,7 +262,7 @@ process_arguments (int argc, char **argv)
                        asprintf (&comm, "%s -%c", comm, c);
                        break;
                default:                                                                        /* help */
-                       usage_va(_("Unknown argument - %s"), optarg);
+                       usage5();
                }
        }
 
index 77df3c2e99c4f0a8cd73ab8624edc636347c2262..e850337b59405bdaa741253459e1611aca28e32e 100644 (file)
@@ -265,8 +265,8 @@ process_arguments (int argc, char **argv)
     case 'a':
       expected_address = optarg;
       break;
-    default:                  /* usage_va */
-      usage_va(_("Unknown argument - %s"), optarg);
+    default:                  /* usage5 */
+      usage5();
     }
   }
 
index 93af7dc56765eb6f52e5f4fa331dbf8d04ad7c17..454f813b30c0bda831874013a4fb30322468abd7 100644 (file)
@@ -370,7 +370,7 @@ process_arguments (int argc, char **argv)
       critical = optarg;
       break;
     default: /* args not parsable */
-      usage_va(_("Unknown argument - %s"), optarg);
+      usage5();
     }
   }
 
index 25ca4a8d3fe4fc888e02a04efab444eca481ecae..4dc48b7744f68b2dd3b55b9eee762a8a2dcebf60 100644 (file)
@@ -258,7 +258,7 @@ process_arguments (int argc, char **argv)
 
     switch (c) {
     case '?':                 /* print short usage statement if args not parsable */
-      usage2 (_("Unknown argument"), optarg);
+      usage5 ();
     case 'h':                 /* help */
       print_help ();
       exit (STATE_OK);
index a785b511317508c655db4670638586517e72932b..79abec33c77bd94bf812d11dbd2db179d4bce0b8 100644 (file)
@@ -249,7 +249,7 @@ process_arguments (int argc, char **argv)
         return ERROR;
       break;
     default: /* args not parsable */
-      usage_va(_("Unknown argument - %s"), optarg);
+      usage5();
     }
   }
 
index 31a76bd2870fdff4e39f96b1a4546d29d1e3469b..8a60ce8c855fd2bcd33a0f756d30c80af73515e4 100644 (file)
@@ -351,7 +351,7 @@ process_arguments (int argc, char **argv)
                        print_help ();
                        exit (STATE_OK);
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index b81f214616be5dc29966cc6ef7b7d9345b67141e..d1f3998b2010ae10f929b08d163ceb86ec0313d8 100644 (file)
@@ -225,7 +225,7 @@ process_arguments (int argc, char **argv)
 
     switch (c) {
     case '?': /* usage */
-      usage2 (_("Unknown argument"), optarg);
+      usage5 ();
       break;
     case 'h': /* help */
       print_help ();
index 14d27b33a181526206e22ec39fb706c79cae8c96..234f23b74b5c08a9f1f9e20050696a137f19a27d 100644 (file)
@@ -212,7 +212,7 @@ main (int argc, char *argv[])
                        print_revision (progname, revision);
                        return STATE_OK;
                default:
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index 60872cfdff2e114358e4a0854983b1323feed147..12ea07135defce944055d7f55cc7365a0d0767fa 100644 (file)
@@ -325,7 +325,7 @@ process_arguments (int argc, char **argv)
 #endif
                        break;
                default:
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index 562eaf5d449066b5fcb857b28958e45277308f13..3d00432f9fba1364d8433c34bb444269f0544b95 100644 (file)
@@ -236,7 +236,7 @@ process_arguments (int argc, char **argv)
                        print_help ();
                        exit (STATE_OK);
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index 7cee31ebcdcf6106e77d37c7c5a4756457e1f7bb..4abe1d767dc668c639b6d3449636091f7a450eb4 100644 (file)
@@ -243,7 +243,7 @@ process_arguments (int argc, char **argv)
                        print_help ();
                        exit (STATE_OK);
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index adaf9e25b9f700e8ddca216bec704006fe5a081f..e587e5cd061fcc4247d6cbe344a7a01f16f145b7 100644 (file)
@@ -277,7 +277,7 @@ process_arguments (int argc, char **argv)
                        print_help ();
                        exit (STATE_OK);
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index e10211faf3396440f6fa7756410f16be4f9825e1..573ec96a8a4aecd6b266063f389cf0ba57f2fa39 100644 (file)
@@ -308,7 +308,7 @@ process_arguments (int argc, char **argv)
                        verbose++;
                        break;
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index ecb7e7fe83cf32f1b529729178b803d2f1b92052..bb62eecf23dd3afafae7d42f0770de9f4dc991e6 100644 (file)
@@ -240,7 +240,7 @@ process_arguments (int argc, char **argv)
                        critical = optarg;
                        break;
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index a6ae71f2e172986636ac5dc2a477804e753a4593..5703e606b7b6e255fa3f568060c07793168017cc 100644 (file)
@@ -258,7 +258,7 @@ process_arguments (int argc, char **argv)
                        verbose++;
                        break;
                default:                                                                        /* print short usage_va statement if args not parsable */
-                       usage_va(_("Unknown argument - %s"), optarg);
+                       usage5();
                }
        }
 
index 44203dbc7127e7711241d04d6540b7eef71c0a10..fe47a58bf4480098dabcfc92fe2097522d492312 100644 (file)
@@ -492,7 +492,7 @@ int process_arguments(int argc, char **argv){
                switch (c)
                        {
                        case '?': /* print short usage statement if args not parsable */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                        case 'h': /* help */
                                print_help();
                                exit(STATE_OK);
index d6e1dd5f506c2b3c328bb82a241bbe801e5e7376..3ed8f3470360131a38103f5cbeaa2d1dbf25d295 100644 (file)
@@ -694,7 +694,7 @@ int process_arguments(int argc, char **argv){
                        break;
                case '?':
                        /* print short usage statement if args not parsable */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                        break;
                }
        }
index 91797dc816f5c9d298dee0fd37e31985c5013687..53ac2e08e4246ccb9d8db65247b5bc8c9304e314 100644 (file)
@@ -1355,7 +1355,7 @@ int process_arguments(int argc, char **argv) {
                switch (c)
                        {
                        case '?': /* print short usage statement if args not parsable */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                        case 'h': /* help */
                                print_help();
                                exit(STATE_OK);
index 2aca8ea5dde8ddcdb00fecc16e068db23e8f78fe..25a7785a8949f39043a02fc026c45e2bec7772f5 100644 (file)
@@ -341,7 +341,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':                                                                       /* print short usage statement if args not parsable */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':                                                                       /* help */
                        print_help ();
                        exit (STATE_OK);
index 41c51413342e6b7b33e35a0421643cb3c64a839e..cbff8d759c10788c3f7b4c9729bbc97cc0734e2f 100644 (file)
@@ -225,7 +225,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':     /* usage */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':     /* help */
                        print_help ();
                        exit (STATE_OK);
index ca40920cd8d1b198bd9edb48ffddfcac8a08ceb2..aa686a65a0e7205506322d078acdb6f5c4ed36c6 100644 (file)
@@ -211,7 +211,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':       /* usage */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':       /* help */
                        print_help ();
                        exit (STATE_OK);
index d9e2a6710a13543ae940564c4c58b880ee4cca4c..da7e9f0f888d6392a9df6949249e958ce2bfddb7 100644 (file)
@@ -359,7 +359,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':                                                                       /* help */
                        print_help ();
                        exit (STATE_OK);
index b1bb928f3e31484b9966538d2f35bc6cadcfd2a0..4b340c3b4d46809c4f4cc36447d26a01af3ad945 100644 (file)
@@ -235,7 +235,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':                                                                       /* print short usage statement if args not parsable */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':                                                                       /* help */
                        print_help ();
                        exit (OK);
index 2d24e1481605e9c1bc7a0bd0529aac2685ea7753..0ccc1c098c6d8e85723a1006fe7d7942f040bd25 100644 (file)
@@ -368,7 +368,7 @@ process_arguments (int argc, char **argv)
                        print_help ();
                        exit (STATE_OK);
                case '?':                                                                       /* usage */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index 94214ee0f92fdf3921cb58b7591d169b58cc494e..94b97c4f3e284249b0806d7dce315159e70640c5 100644 (file)
@@ -664,7 +664,7 @@ process_arguments (int argc, char **argv)
                        print_help ();
                        exit (STATE_OK);
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index 1e1657b4f91651ce02fb30baa60e5715b14ae781..d9e007820739c28b53b4d2873a6d832405e0eeec 100644 (file)
@@ -444,7 +444,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':       /* usage */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':       /* help */
                        print_help ();
                        exit (STATE_OK); 
index 1c24e5889c460525910d55baa793ce6d08c86f4e..afe44c9512d668f9410393cddaf89bf838970dbd 100644 (file)
@@ -128,7 +128,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'V':                                                                       /* version */
                        print_revision (progname, revision);
                        exit (STATE_OK);
index 59c1ecf6ce2d902d7298de4fd25e67d659dff427..1903a00617855b225874abae588450499f2dce03 100644 (file)
@@ -468,7 +468,7 @@ process_arguments (int argc, char **argv)
                        print_help ();
                        exit (STATE_OK);
                case '?':                                                                       /* error */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index faa3cedb99c3d60d9fda8b57b1d4084da86c0528..7e1bd38b043be9059075803aa1fd33ec1c192dd9 100644 (file)
@@ -443,7 +443,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':                 /* print short usage statement if args not parsable */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':                 /* help */
                        print_help ();
                        exit (STATE_OK);
index ca4205663e10176ce75454db502143547a573c1c..d3af3b0cef944242fb97055e5455620c935fea7c 100644 (file)
@@ -232,7 +232,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':                                                                       /* print short usage statement if args not parsable */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':                                                                       /* help */
                        print_help ();
                        exit (STATE_OK);
index 280b3fb6c0489821ee03c7eb79ca26017c48a5d3..56438bb28007b0d019113b4e62ef62a6c34a1232 100644 (file)
@@ -494,7 +494,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':                                                                       /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'H':                                                                       /* hostname */
                        if (is_host (optarg)) {
                                server_address = optarg;
index 0c62e3b118fe41ec1057ba8b93e7072adef658c2..8e5f23d72a17e86ef886829fb69bfdf24a0a1e4c 100644 (file)
@@ -156,7 +156,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':                                                                       /* print short usage statement if args not parsable */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                case 'h':                                                                       /* help */
                        print_help ();
                        exit (STATE_OK);
index 45c032691d07002b99f025720859a4e3ac9327ad..8b2dff0e6ba86c6a2e42e857d06f5026130fa246 100644 (file)
@@ -189,7 +189,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':     /* help */
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                        break;
                case 'h':     /* help */
                        print_help ();
index 7793e9a8604165f5a253674628d09753572d097a..612dd14daf7ed6ee87b4ce6f8e233756d12253e3 100644 (file)
@@ -100,7 +100,7 @@ main (int argc, char **argv)
                        break;
                case '?':
                default:
-                       usage2 (_("Unknown argument"), optarg);
+                       usage5 ();
                }
        }
 
index 2b3accea672e2050f2f82abbf1d7962d479c550d..7e1e58a20060187204b4fb523632c5d418465a2e 100644 (file)
@@ -94,6 +94,13 @@ usage4 (const char *msg)
        exit (STATE_UNKNOWN);
 }
 
+void
+usage5 (void)
+{
+       print_usage();
+       exit (STATE_UNKNOWN);
+}
+
 char *
 clean_revstring (const char *revstring)
 {
index 0d00ce85cef9fd759b85e04c36626d1376adcdb3..f15a7b161de69541a59629198f622fa30e89d30e 100644 (file)
@@ -80,8 +80,9 @@ int max_state (int a, int b);
 void usage (const char *) __attribute__((noreturn));
 void usage2(const char *, const char *) __attribute__((noreturn));
 void usage3(const char *, int) __attribute__((noreturn));
-void usage4(const char *);
-void usage_va(const char *fmt, ...);
+void usage4(const char *) __attribute__((noreturn));
+void usage5(void) __attribute__((noreturn));
+void usage_va(const char *fmt, ...) __attribute__((noreturn));
 
 const char *state_text (int);