From 910894a4e255cdb88e37f17a06f1393853544b84 Mon Sep 17 00:00:00 2001 From: Kostyantyn Hushchyn Date: Tue, 14 Dec 2010 12:51:25 +0200 Subject: check_cluster.c: Added data argument validation. Signed-off-by: Kostyantyn Hushchyn --- plugins/check_cluster.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/check_cluster.c b/plugins/check_cluster.c index b86e501d..e1ede9f7 100644 --- a/plugins/check_cluster.c +++ b/plugins/check_cluster.c @@ -143,6 +143,7 @@ int main(int argc, char **argv){ int process_arguments(int argc, char **argv){ int c; + char *ptr; int option=0; static struct option longopts[]={ {"data", required_argument,0,'d'}, @@ -188,6 +189,15 @@ int process_arguments(int argc, char **argv){ case 'd': /* data values */ data_vals=(char *)strdup(optarg); + /* validate data */ + for (ptr=data_vals;ptr!=NULL;ptr+=2){ + if (ptr[0]<'0' || ptr[0]>'3') + return ERROR; + if (ptr[1]=='\0') + break; + if (ptr[1]!=',') + return ERROR; + } break; case 'l': /* text label */ -- cgit v1.2.3-74-g34f1