Просмотр исходного кода

Merge pull request #739 from nagios-plugins/720-check_snmp-int-bug

Fixes #720 - check_snmp numeric OID name bug
Sebastian Wolf 2 лет назад
Родитель
Сommit
1377084b3a
2 измененных файлов с 7 добавлено и 3 удалено
  1. 2 1
      NEWS
  2. 5 2
      plugins/check_snmp.c

+ 2 - 1
NEWS

@@ -4,7 +4,8 @@ This file documents the major additions and syntax changes between releases.
 	FIXES
 	check_ntp.pl: Fix warning/critical threshold information missing from performance data output (#735)
 	check_ntp.pl: Fix issues when NTP server has a positive time offset (#734)
-	check_snmp: Fixed issue where plugin returned OK for missin OID (#679)
+	check_snmp: Fixed issue where plugin returned OK for missing OID (#679)
+	check_snmp: Fixed issue where OID name with numeric data was misinterpreted as OID value (#720)
 
 2.4.6 2023-08-01
 	FIXES

+ 5 - 2
plugins/check_snmp.c

@@ -490,6 +490,7 @@ main (int argc, char **argv)
 			is_ticks = 1;
 		}
 		else {
+			/* This branch is expected to be error-handling only */
 			show = response;
 			show_length = strlen(show);
 			for (int i = 0; i < show_length; i++){
@@ -503,10 +504,12 @@ main (int argc, char **argv)
 		/* Process this block for numeric comparisons */
 		/* Make some special values,like Timeticks numeric only if a threshold is defined */
 		if (thlds[i]->warning || thlds[i]->critical || calculate_rate || is_ticks || offset != 0.0 || multiplier != 1.0) {
-			ptr = strpbrk (show, "-0123456789");
-
+			/* Find the first instance of the '(' character - the value of the OID should be contained in parens */
+			ptr = strpbrk(show, "(");
 			if (ptr == NULL)
 				die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
+			ptr++; /* Move to the first character after the '(' */
+			
 			while (i >= response_size) {
 				response_size += OID_COUNT_STEP;
 				response_value = realloc(response_value, response_size * sizeof(*response_value));