Browse Source

Bug 727511 - ldclt SSL search requests are failing with "illegal error number -1" error

https://bugzilla.redhat.com/show_bug.cgi?id=727511
Resolves: bug 727511
Bug Description: ldclt SSL search requests are failing with "illegal error number -1" error
Reviewed by: me
Branch: master
Fix Description: Fix coverity NULL deref defect
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
Rich Megginson 14 years ago
parent
commit
d2d1b52f4b
1 changed files with 10 additions and 5 deletions
  1. 10 5
      ldap/servers/slapd/tools/ldclt/ldapfct.c

+ 10 - 5
ldap/servers/slapd/tools/ldclt/ldapfct.c

@@ -641,11 +641,16 @@ ldclt_clientauth(thread_context	*tttctx, const char *path, const char *certname,
   char *token_name = NULL;
   PK11SlotInfo *slot = NULL;
   int rc = 0;
+  int thrdNum = 0;
+
+  if (tttctx) {
+      thrdNum = tttctx->thrdNum;
+  }
 
   rc = NSS_Initialize(path, "", "", SECMOD_DB, NSS_INIT_READONLY);
   if (rc != SECSuccess) {
     printf ("ldclt[%d]: T%03d: Cannot NSS_Initialize(%s) %d\n",
-	    mctx.pid, tttctx->thrdNum, path, PR_GetError());
+	    mctx.pid, thrdNum, path, PR_GetError());
     fflush(stdout);
     goto done;
   }
@@ -662,7 +667,7 @@ ldclt_clientauth(thread_context	*tttctx, const char *path, const char *certname,
 
   if (!slot) {
     printf ("ldclt[%d]: T%03d: Cannot find slot for token %s - %d\n",
-	    mctx.pid, tttctx->thrdNum,
+	    mctx.pid, thrdNum,
 	    token_name ? token_name : "internal", PR_GetError());
     fflush(stdout);
     goto done;
@@ -675,7 +680,7 @@ ldclt_clientauth(thread_context	*tttctx, const char *path, const char *certname,
   rc = PK11_Authenticate(slot, PR_FALSE, (void *)pwd);
   if (rc != SECSuccess) {
     printf ("ldclt[%d]: T%03d: Cannot authenticate to token %s - %d\n",
-	    mctx.pid, tttctx->thrdNum,
+	    mctx.pid, thrdNum,
 	    token_name ? token_name : "internal", PR_GetError());
     fflush(stdout);
     goto done;
@@ -683,14 +688,14 @@ ldclt_clientauth(thread_context	*tttctx, const char *path, const char *certname,
 
   if ((rc = ldap_set_option(tttctx->ldapCtx, LDAP_OPT_X_TLS_CERTFILE, certname))) {
     printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(ld, LDAP_OPT_X_CERTFILE, %s), errno=%d ldaperror=%d:%s\n",
-	    mctx.pid, tttctx->thrdNum, certname, errno, rc, my_ldap_err2string(rc));
+	    mctx.pid, thrdNum, certname, errno, rc, my_ldap_err2string(rc));
     fflush (stdout);
     goto done;
   }
 
   if ((rc = ldap_set_option(tttctx->ldapCtx, LDAP_OPT_X_TLS_KEYFILE, pwd))) {
     printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(ld, LDAP_OPT_X_KEYFILE, %s), errno=%d ldaperror=%d:%s\n",
-	    mctx.pid, tttctx->thrdNum, pwd, errno, rc, my_ldap_err2string(rc));
+	    mctx.pid, thrdNum, pwd, errno, rc, my_ldap_err2string(rc));
     fflush (stdout);
     goto done;
   }