summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Nierlein <sven@nierlein.org>2018-12-07 17:35:58 +0100
committerGitHub <noreply@github.com>2018-12-07 17:35:58 +0100
commitac6f101f057caa3083c092537e6dff97328cfd44 (patch)
treefb70fda138265fb14793729146ae55270d1f04d2
parentc7c4be2ad1fa97d5b8db0cff5f7204c605992047 (diff)
parent910894a4e255cdb88e37f17a06f1393853544b84 (diff)
downloadmonitoring-plugins-ac6f101.tar.gz
Merge pull request #1564 from jacobbaungard/check_cluster_arg_validation
check_cluster.c: Added data argument validation.
-rw-r--r--plugins/check_cluster.c10
1 files changed, 10 insertions, 0 deletions
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){
143 143
144int process_arguments(int argc, char **argv){ 144int 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 */