diff options
author | Spenser Reinhardt <sreinhardt@nagios.com> | 2014-06-22 22:59:03 -0500 |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2014-06-28 18:23:09 +0200 |
commit | 88472d1804d3cd42e0ea8717d75191dfb3e3bbeb (patch) | |
tree | ed8a8c5e3d126684963cef791087ebd0fa45fbf0 /plugins | |
parent | e7e6edb2f8e43085d02cdda93fe16256ab3a35fe (diff) | |
download | monitoring-plugins-88472d1.tar.gz |
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
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/negate.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/plugins/negate.c b/plugins/negate.c index 4bd09deb..7787d018 100644 --- a/plugins/negate.c +++ b/plugins/negate.c | |||
@@ -98,8 +98,7 @@ main (int argc, char **argv) | |||
98 | die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n")); | 98 | die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n")); |
99 | 99 | ||
100 | for (i = 0; i < chld_out.lines; i++) { | 100 | for (i = 0; i < chld_out.lines; i++) { |
101 | if (subst_text && result != state[result] && | 101 | if (subst_text && result >= 0 && result <= 4 && result != state[result]) { |
102 | result >= 0 && result <= 4) { | ||
103 | /* Loop over each match found */ | 102 | /* Loop over each match found */ |
104 | while ((sub = strstr (chld_out.line[i], state_text (result)))) { | 103 | while ((sub = strstr (chld_out.line[i], state_text (result)))) { |
105 | /* Terminate the first part and skip over the string we'll substitute */ | 104 | /* Terminate the first part and skip over the string we'll substitute */ |