[monitoring-plugins] plugins/negate.c - Reorder if statement, aiob

Jan Wagner git at monitoring-plugins.org
Sat Jun 28 22:20:08 CEST 2014


    Module: monitoring-plugins
    Branch: master
    Commit: 88472d1804d3cd42e0ea8717d75191dfb3e3bbeb
    Author: Spenser Reinhardt <sreinhardt at nagios.com>
 Committer: Jan Wagner <waja at cyconet.org>
      Date: Sun Jun 22 22:59:03 2014 -0500
       URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=88472d1

plugins/negate.c - Reorder if statement, aiob

Coverity 66480 - Potential array index out of bounds, since result was not verified to be positive prior to using as an index for state[]. Simply reording the if statement should resolve the issue. - SR

---

 plugins/negate.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/plugins/negate.c b/plugins/negate.c
index 4bd09de..7787d01 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -98,8 +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 != state[result] &&
-		    result >= 0 && result <= 4) {
+		if (subst_text && result >= 0 && result <= 4 && 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 */



More information about the Commits mailing list