aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f6966721..bd060218 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -233,9 +233,10 @@ process_arguments (int argc, char **argv)
struct name_list **fstail = &fs_exclude_list;
struct name_list **dptail = &dp_exclude_list;
struct name_list *temp_list;
- unsigned long l;
int result = OK;
+ unsigned long l;
+
int option_index = 0;
static struct option long_options[] = {
{"timeout", required_argument, 0, 't'},
@@ -322,6 +323,8 @@ process_arguments (int argc, char **argv)
usage (_("Critical threshold must be integer or percentage!\n"));
}
case 'u':
+ if (units)
+ free(units);
if (! strcmp (optarg, "bytes")) {
mult = (uintmax_t)1;
units = strdup ("B");
@@ -340,13 +343,19 @@ process_arguments (int argc, char **argv)
} else {
die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
}
+ if (units == NULL)
+ die (STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units");
break;
case 'k': /* display mountpoint */
mult = 1024;
+ if (units)
+ free(units);
units = strdup ("kB");
break;
case 'm': /* display mountpoint */
mult = 1024 * 1024;
+ if (units)
+ free(units);
units = strdup ("kB");
break;
case 'l':
@@ -475,8 +484,10 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
return ERROR;
}
- if (units == NULL)
+ if (units == NULL) {
units = strdup ("MB");
+ mult = (uintmax_t)1024 * 1024;
+ }
return OK;
}