Browse Source

Ticket #48400 - ldclt - segmentation fault error while binding

Descrition: When "-e randombinddn,randombinddnlow=LOW,randombinddnhigh=HIGH"
is given, spaces for bufBaseDN and bufPasswd in the context were not
allocated.  The part of the code was enabled only when NEED_FILTER is
set.  This patch loosened the condition.

https://fedorahosted.org/389/ticket/48400

Reviewed by [email protected] (Thank you, William!)
Noriko Hosoi 10 years ago
parent
commit
005000430e
1 changed files with 45 additions and 45 deletions
  1. 45 45
      ldap/servers/slapd/tools/ldclt/threadMain.c

+ 45 - 45
ldap/servers/slapd/tools/ldclt/threadMain.c

@@ -890,78 +890,78 @@ threadMain (
 	}
       }
     }								/*JLS 23-03-01*/
+  }								/*JLS 05-03-01*/
 
-    /*
-     * Variable base DN ?
-     */
-    tttctx->bufBaseDN = (char *) malloc (strlen (mctx.baseDN) + 1);
-    if (tttctx->bufBaseDN == NULL)				/*JLS 06-03-00*/
-    {								/*JLS 06-03-00*/
+  /*
+   * Variable base DN ?
+   */
+  tttctx->bufBaseDN = (char *) malloc (strlen (mctx.baseDN) + 1);
+  if (tttctx->bufBaseDN == NULL)				/*JLS 06-03-00*/
+  {								/*JLS 06-03-00*/
       printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufBaseDN), error=%d (%s)\n",
 		mctx.pid, tttctx->thrdNum, errno, strerror (errno));
       ldcltExit (EXIT_INIT);					/*JLS 18-12-00*/
-    }								/*JLS 06-03-00*/
-    if (!(mctx.mode & RANDOM_BASE))
+  }								/*JLS 06-03-00*/
+  if (!(mctx.mode & RANDOM_BASE))
       strcpy (tttctx->bufBaseDN, mctx.baseDN);
-    else
-    {
+  else
+  {
       tttctx->startBaseDN = strlen (mctx.baseDNHead);
       strcpy (tttctx->bufBaseDN, mctx.baseDNHead);
       strcpy (&(tttctx->bufBaseDN[tttctx->startBaseDN+mctx.baseDNNbDigit]),
 			mctx.baseDNTail);
-    }
+  }
 
-    /*
-     * Variable bind DN ?
-     * Do not forget the random bind password below that is activated
-     * at the same time as the random bind DN.
-     */
-    if (mctx.bindDN != NULL)					/*JLS 05-03-01*/
-    {								/*JLS 05-03-01*/
+  /*
+   * Variable bind DN ?
+   * Do not forget the random bind password below that is activated
+   * at the same time as the random bind DN.
+   */
+  if (mctx.bindDN != NULL)					/*JLS 05-03-01*/
+  {								/*JLS 05-03-01*/
       tttctx->bufBindDN = (char *) malloc (strlen (mctx.bindDN) + 1);
       if (tttctx->bufBindDN == NULL)
       {
-	printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufBindDN), error=%d (%s)\n",
-		mctx.pid, tttctx->thrdNum, errno, strerror (errno));
-	ldcltExit (EXIT_INIT);
+           printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufBindDN), error=%d (%s)\n",
+               mctx.pid, tttctx->thrdNum, errno, strerror (errno));
+           ldcltExit (EXIT_INIT);
       }
       if (!(mctx.mode & RANDOM_BINDDN))
-	strcpy (tttctx->bufBindDN, mctx.bindDN);
+          strcpy (tttctx->bufBindDN, mctx.bindDN);
       else
       {
-	tttctx->startBindDN = strlen (mctx.bindDNHead);
-	strcpy (tttctx->bufBindDN, mctx.bindDNHead);
-	strcpy (&(tttctx->bufBindDN[tttctx->startBindDN+mctx.bindDNNbDigit]),
-			mctx.bindDNTail);
+          tttctx->startBindDN = strlen (mctx.bindDNHead);
+          strcpy (tttctx->bufBindDN, mctx.bindDNHead);
+          strcpy (&(tttctx->bufBindDN[tttctx->startBindDN+mctx.bindDNNbDigit]),
+                  mctx.bindDNTail);
       }
-    }								/*JLS 05-03-01*/
+  }								/*JLS 05-03-01*/
 
-    /*
-     * Variable bind password ?
-     * Remember that the random bind password feature is activated
-     * by the same option as the random bind DN, but has here its own
-     * code section for the ease of coding.
-     */
-    if (mctx.passwd != NULL)					/*JLS 05-03-01*/
-    {								/*JLS 05-03-01*/
+  /*
+   * Variable bind password ?
+   * Remember that the random bind password feature is activated
+   * by the same option as the random bind DN, but has here its own
+   * code section for the ease of coding.
+   */
+  if (mctx.passwd != NULL)					/*JLS 05-03-01*/
+  {								/*JLS 05-03-01*/
       tttctx->bufPasswd = (char *) malloc (strlen (mctx.passwd) + 1);
       if (tttctx->bufPasswd == NULL)
       {
-	printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufPasswd), error=%d (%s)\n",
-		mctx.pid, tttctx->thrdNum, errno, strerror (errno));
-	ldcltExit (EXIT_INIT);
+          printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufPasswd), error=%d (%s)\n",
+                  mctx.pid, tttctx->thrdNum, errno, strerror (errno));
+          ldcltExit (EXIT_INIT);
       }
       if (!(mctx.mode & RANDOM_BINDDN))
-	strcpy (tttctx->bufPasswd, mctx.passwd);
+          strcpy (tttctx->bufPasswd, mctx.passwd);
       else
       {
-	tttctx->startPasswd = strlen (mctx.passwdHead);
-	strcpy (tttctx->bufPasswd, mctx.passwdHead);
-	strcpy (&(tttctx->bufPasswd[tttctx->startPasswd+mctx.passwdNbDigit]),
-			mctx.passwdTail);
+          tttctx->startPasswd = strlen (mctx.passwdHead);
+          strcpy (tttctx->bufPasswd, mctx.passwdHead);
+          strcpy (&(tttctx->bufPasswd[tttctx->startPasswd+mctx.passwdNbDigit]),
+                  mctx.passwdTail);
       }
-    }
-  }								/*JLS 05-03-01*/
+  }
 
   /*
    * Bind DN from a file ?