Blame SOURCES/0021-Ticket-48203-Fix-coverity-issues-07-14-2015.patch

a2f18f
From e88ffac24b49acb01fb7d460ff4282abe85d3799 Mon Sep 17 00:00:00 2001
a2f18f
From: Noriko Hosoi <nhosoi@redhat.com>
a2f18f
Date: Tue, 14 Jul 2015 16:00:03 -0700
a2f18f
Subject: [PATCH 21/22] Ticket #48203 - Fix coverity issues - 07/14/2015
a2f18f
a2f18f
Description: Overrunning array "mctx.negativeErrors" of 19 4-byte
a2f18f
elements at element index 122 (byte offset 488) using index "abs(err)"
a2f18f
(which evaluates to 122).
a2f18f
a2f18f
Commit 71be5faaa478593bb056887410ca8e48e05b2fe4 to fix Ticket #47799
a2f18f
introduced this problem.  The error count checking has to be done per
a2f18f
error.
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/48203
a2f18f
a2f18f
Reviewed by rmeggins@redhat.com (Thank you, Rich!)
a2f18f
a2f18f
(cherry picked from commit cc435b8c382f7da662b5c27339d23fd33a8f4117)
a2f18f
(cherry picked from commit 6ec1001e507908ba60f8c52568d24b5c7c727855)
a2f18f
---
a2f18f
 ldap/servers/slapd/tools/ldclt/threadMain.c | 20 +++++++++++++++++---
a2f18f
 1 file changed, 17 insertions(+), 3 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/servers/slapd/tools/ldclt/threadMain.c b/ldap/servers/slapd/tools/ldclt/threadMain.c
a2f18f
index 5d915fd..88353c6 100644
a2f18f
--- a/ldap/servers/slapd/tools/ldclt/threadMain.c
a2f18f
+++ b/ldap/servers/slapd/tools/ldclt/threadMain.c
a2f18f
@@ -477,7 +477,7 @@ addErrorStat (
a2f18f
 #else
a2f18f
     if ((err <= 0) || (err >= MAX_ERROR_NB))
a2f18f
 #endif
a2f18f
-	{
a2f18f
+    {
a2f18f
       if (mctx.errorsBad > mctx.maxErrors) {
a2f18f
         printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
a2f18f
         (void) printGlobalStatistics();				/*JLS 25-08-00*/
a2f18f
@@ -485,8 +485,22 @@ addErrorStat (
a2f18f
         ldclt_sleep (5);
a2f18f
         ldcltExit (EXIT_MAX_ERRORS);				/*JLS 25-08-00*/
a2f18f
       }
a2f18f
-    } else {
a2f18f
-      if (mctx.errors[err] + mctx.negativeErrors[abs(err)] > mctx.maxErrors) {
a2f18f
+    }
a2f18f
+#if defined(USE_OPENLDAP)
a2f18f
+    else if (err < 0)
a2f18f
+    {
a2f18f
+      if (mctx.negativeErrors[abs(err)] > mctx.maxErrors) {
a2f18f
+        printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
a2f18f
+        (void) printGlobalStatistics();				/*JLS 25-08-00*/
a2f18f
+        fflush (stdout);
a2f18f
+        ldclt_sleep (5);
a2f18f
+        ldcltExit (EXIT_MAX_ERRORS);				/*JLS 25-08-00*/
a2f18f
+      }
a2f18f
+    }
a2f18f
+#endif
a2f18f
+    else
a2f18f
+    {
a2f18f
+      if (mctx.errors[err] > mctx.maxErrors) {
a2f18f
         printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
a2f18f
         (void) printGlobalStatistics();				/*JLS 25-08-00*/
a2f18f
         fflush (stdout);
a2f18f
-- 
a2f18f
1.9.3
a2f18f