diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-11-08 08:07:37 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-11-08 08:07:37 +0000 |
commit | 4f45392acb8e67e86b92b3707eba49ef9aeee574 (patch) | |
tree | 4ed9fe09faf2b3b9720b9438695ac4a50079c61e | |
parent | b39ae71c60f0039cda60590715fc17f92107ac35 (diff) | |
download | monitoring-plugins-4f45392acb8e67e86b92b3707eba49ef9aeee574.tar.gz |
user reports NULL still getting into asprintf
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@176 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | plugins/check_snmp.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 4a51a294..de019bac 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -415,9 +415,6 @@ process_arguments (int argc, char **argv) strcpy (argv[c], "-c"); } - /* initialize some args */ - asprintf (&oid, ""); - while (1) { #ifdef HAVE_GETOPT_H c = @@ -453,7 +450,7 @@ process_arguments (int argc, char **argv) ptr[0] = ' '; /* relpace comma with space */ for (ptr = optarg; (ptr = index (ptr, ' ')); ptr++) eval_method[++j] |= WARN_PRESENT; - asprintf (&oid, "%s %s", oid, optarg); + asprintf (&oid, "%s %s", (oid?oid:""), optarg); break; case 'E': /* PRELIMINARY - may change */ eval_method[j] |= WARN_PRESENT; @@ -461,7 +458,7 @@ process_arguments (int argc, char **argv) ptr[0] = ' '; /* relpace comma with space */ for (ptr = optarg; (ptr = index (ptr, ' ')); ptr++) eval_method[++j] |= CRIT_PRESENT; - asprintf (&oid, "%s %s", oid, optarg); + asprintf (&oid, "%s %s", (oid?oid:""), optarg); break; case 'c': /* critical time threshold */ if (strspn (optarg, "0123456789:,") < strlen (optarg)) { @@ -500,10 +497,9 @@ process_arguments (int argc, char **argv) case 'o': /* object identifier */ for (ptr = optarg; (ptr = index (ptr, ',')); ptr++) ptr[0] = ' '; /* relpace comma with space */ - for (ptr = optarg; (ptr = index (ptr, ' ')); ptr++) { + for (ptr = optarg; (ptr = index (ptr, ' ')); ptr++) j++; /* count OIDs */ - } - asprintf (&oid, "%s %s", oid, optarg); + asprintf (&oid, "%s %s", (oid?oid:""), optarg); break; case 'd': /* delimiter */ delimiter = strscpy (delimiter, optarg); |