diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_snmp.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 7c3bc4b9..d2f2f8b5 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -150,16 +150,18 @@ static char *fix_snmp_range(char *th) | |||
150 | { | 150 | { |
151 | double left, right; | 151 | double left, right; |
152 | char *colon, *ret; | 152 | char *colon, *ret; |
153 | if (!(colon = strchr(th, ':'))) | 153 | |
154 | if ((colon = strchr(th, ':')) == NULL || *(colon + 1) == '\0') | ||
154 | return th; | 155 | return th; |
155 | *colon = 0; | ||
156 | 156 | ||
157 | left = strtod(th, NULL); | 157 | left = strtod(th, NULL); |
158 | right = strtod(colon + 1, NULL); | 158 | right = strtod(colon + 1, NULL); |
159 | if (right >= left) { | 159 | if (right >= left) |
160 | return th; | 160 | return th; |
161 | } | 161 | |
162 | ret = malloc(strlen(th) + strlen(colon + 1) + 2); | 162 | if ((ret = malloc(strlen(th) + 2)) == NULL) |
163 | die(STATE_UNKNOWN, _("Cannot malloc")); | ||
164 | *colon = '\0'; | ||
163 | sprintf(ret, "@%s:%s", colon + 1, th); | 165 | sprintf(ret, "@%s:%s", colon + 1, th); |
164 | free(th); | 166 | free(th); |
165 | return ret; | 167 | return ret; |