[Nagiosplug-devel] check_dns coredump on solaris

Jason Martin jhmartin at toger.us
Fri Feb 6 12:28:00 CET 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Check_dns has a bug in that it coredumps if called w/invalid arguments. It 
appears to be a result of a printf that assumes a 'optarg' will be 
provided, even when invalid arguments are passed. Attached is a unified 
diff that prevents the printf of a null pointer.

check_dns (nagios-plugins 1.3.1) 1.8.2.3
on
SunOS comanche 5.9 Generic sun4u sparc SUNW,Ultra-60
SunOS snaketales 5.8 Generic_108528-27 sun4u sparc SUNW,Ultra-60
SunOS htvsim01 5.6 Generic_105181-16 sun4m sparc SUNW,SPARCstation-10

Thanks,
- -Jason Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.3.3 (GNU/Linux)
Comment: pgpenvelope 2.10.2 - http://pgpenvelope.sourceforge.net/

iD8DBQFAIZTUl2ODWuqVSBMRAp0gAJ9aZeSb/hhgiEbPFS+Op95kGkKlsgCgl7Ld
Pxm2fLxCC4czmrHm8cwWdXA=
=nMLR
-----END PGP SIGNATURE-----
-------------- next part --------------
--- check_dns.c	Sat May 31 07:39:33 2003
+++ /tmp/check_dns.c	Wed Feb  4 16:30:36 2004
@@ -301,13 +301,13 @@
 #else
 		c = getopt (argc, argv, "hVvt:H:s:r:a:");
 #endif
-
 		if (c == -1 || c == EOF)
 			break;
-
+/* JHM + TEC  2-4-04  - Added if statement in line 309 - to make sure the arg exists. corrected CORE Dump issue with invalid option */
 		switch (c) {
 		case '?': /* args not parsable */
-			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
+		if (optarg != NULL)
+                        printf ("%s: Unknown argument: %s\n\n", progname, "optarg") ;
 			print_usage ();
 			exit (STATE_UNKNOWN);
 		case 'h': /* help */
@@ -323,7 +323,7 @@
 			timeout_interval = atoi (optarg);
 			break;
 		case 'H': /* hostname */
-			if (is_host (optarg) == FALSE) {
+			if (optarg==NULL || is_host (optarg) == FALSE) {
 				printf ("Invalid host name/address\n\n");
 				print_usage ();
 				exit (STATE_UNKNOWN);


More information about the Devel mailing list