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