Skip to content
Browse files

MKN: Add some checking to numeric gmetric parameters.

  • Loading branch information...
1 parent 92a0f13 commit 63b1160eadac3f71df28a9b32349da07b55b148a knobi1 committed Jan 25, 2006
Showing with 25 additions and 0 deletions.
  1. +25 −0 monitor-core/lib/libgmond.c
View
25 monitor-core/lib/libgmond.c
@@ -696,6 +696,23 @@ Ganglia_gmetric_destroy( Ganglia_gmetric gmetric )
}
+int
+check_value( char *type, char* value)
+{
+char *tail;
+int ret=1;
+
+ if (strcmp(type,"float")||strcmp(type,"double"))
+ strtod(value,&tail);
+ else
+ strtol(value,&tail,10);
+
+ if(strlen(tail)==0)
+ ret=0;
+
+ return ret;
+}
+
/*
* struct Ganglia_gmetric_message {
* char *type;
@@ -728,6 +745,14 @@ Ganglia_gmetric_set( Ganglia_gmetric gmetric, char *name, char *value, char *typ
return 3;
}
+ /* Make sure we have a number for (int8|uint8|int16|uint16|int32|uint32|float|double)*/
+ if(strcmp(type,"int8")||strcmp(type,"uint8")||
+ strcmp(type,"int16")||strcmp(type,"uint16")||strcmp(type,"int32")||
+ strcmp(type,"uint32")||strcmp(type,"float")||strcmp(type,"double"))
+ {
+ if(check_value(type,value)) return 4;
+ }
+
/* All the data is there and validated... copy it into the structure */
gmetric->msg->name = apr_pstrdup( gmetric->pool, name);
gmetric->msg->value = apr_pstrdup( gmetric->pool, value);

0 comments on commit 63b1160

Please sign in to comment.
Something went wrong with that request. Please try again.