Ver código fonte

negate.c - array out of bounds

state[] is a 4 value array, allowing result to be less than or equal to 4, would cause and index out of bounds error as we can only read from 0-3. Setting < 4 would work but is less clear than using 0 <= result <= 3, which are the accepted nagios return codes.

coverity 103715
Spenser Reinhardt 11 anos atrás
pai
commit
f7b441b24b
1 arquivos alterados com 1 adições e 1 exclusões
  1. 1 1
      plugins/negate.c

+ 1 - 1
plugins/negate.c

@@ -98,7 +98,7 @@ main (int argc, char **argv)
 		die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n"));
 
 	for (i = 0; i < chld_out.lines; i++) {
-		if (subst_text && result >= 0 && result <= 4 && result != state[result])  {
+		if (subst_text && result >= 0 && result <= 3 && result != state[result])  {
 			/* Loop over each match found */
 			while ((sub = strstr (chld_out.line[i], state_text (result)))) {
 				/* Terminate the first part and skip over the string we'll substitute */