diff options
author | Kostyantyn Hushchyn <kgushtin@op5.com> | 2010-12-14 10:51:25 (GMT) |
---|---|---|
committer | Jacob Hansen <jhansen@op5.com> | 2018-11-29 15:37:59 (GMT) |
commit | 910894a4e255cdb88e37f17a06f1393853544b84 (patch) | |
tree | 43abff5844d286cff6e12ac8994fd2dd7f763980 | |
parent | c285edd2f34582c954a720317c3feba37aa1a33a (diff) | |
download | monitoring-plugins-910894a4e255cdb88e37f17a06f1393853544b84.tar.gz |
check_cluster.c: Added data argument validation.refs/pull/1564/head
Signed-off-by: Kostyantyn Hushchyn <kgushtin@op5.com>
-rw-r--r-- | plugins/check_cluster.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/check_cluster.c b/plugins/check_cluster.c index b86e501..e1ede9f 100644 --- a/plugins/check_cluster.c +++ b/plugins/check_cluster.c | |||
@@ -143,6 +143,7 @@ int main(int argc, char **argv){ | |||
143 | 143 | ||
144 | int process_arguments(int argc, char **argv){ | 144 | int process_arguments(int argc, char **argv){ |
145 | int c; | 145 | int c; |
146 | char *ptr; | ||
146 | int option=0; | 147 | int option=0; |
147 | static struct option longopts[]={ | 148 | static struct option longopts[]={ |
148 | {"data", required_argument,0,'d'}, | 149 | {"data", required_argument,0,'d'}, |
@@ -188,6 +189,15 @@ int process_arguments(int argc, char **argv){ | |||
188 | 189 | ||
189 | case 'd': /* data values */ | 190 | case 'd': /* data values */ |
190 | data_vals=(char *)strdup(optarg); | 191 | data_vals=(char *)strdup(optarg); |
192 | /* validate data */ | ||
193 | for (ptr=data_vals;ptr!=NULL;ptr+=2){ | ||
194 | if (ptr[0]<'0' || ptr[0]>'3') | ||
195 | return ERROR; | ||
196 | if (ptr[1]=='\0') | ||
197 | break; | ||
198 | if (ptr[1]!=',') | ||
199 | return ERROR; | ||
200 | } | ||
191 | break; | 201 | break; |
192 | 202 | ||
193 | case 'l': /* text label */ | 203 | case 'l': /* text label */ |