~ubuntu-branches/ubuntu/utopic/389-ds-base/utopic-proposed

« back to all changes in this revision

Viewing changes to ldap/servers/slapd/tools/ldclt/ldapfct.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2014-02-03 11:08:50 UTC
  • mfrom: (0.2.1)
  • Revision ID: package-import@ubuntu.com-20140203110850-tjzx85elnke9fiu3
Tags: 1.3.2.9-1
* New upstream release.
  - fixes CVE-2013-0336 (Closes: #704077)
  - fixes CVE-2013-1897 (Closes: #704421)
  - fixes CVE-2013-2219 (Closes: #718325)
  - fixes CVE-2013-4283 (Closes: #721222)
  - fixes CVE-2013-4485 (Closes: #730115)
* Drop fix-CVE-2013-0312.diff, upstream.
* rules: Add new scripts to rename.
* fix-sasl-path.diff: Use a triplet path to find libsasl2. (LP:
  #1088822)
* admin_scripts.diff: Add patch from upstream #47511 to fix bashisms.
* control: Add ldap-utils to -base depends.
* rules, rename-online-scripts.diff: Some scripts with .pl suffix are
  meant for an online server, so instead of overwriting the offline
  scripts use -online suffix.
* rules: Enable parallel build, but limit the jobs to 1 for
  dh_auto_install.
* control: Bump policy to 3.9.5, no changes.
* rules: Add get-orig-source target.
* lintian-overrides: Drop obsolete entries, add comments for the rest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
442
442
  if (mctx.mode & STRING)
443
443
    (void) randomString (tttctx, mctx.bindDNNbDigit);
444
444
  else
445
 
    rnd (tttctx->buf2, mctx.bindDNLow, mctx.bindDNHigh, mctx.bindDNNbDigit);
 
445
    rnd (tttctx->buf2, mctx.bindDNLow, mctx.bindDNHigh, (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.bindDNNbDigit);
446
446
 
447
447
  /*
448
448
   * First, randomize the bind DN.
732
732
connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2)
733
733
{
734
734
  LDAP *ld = NULL;
735
 
  const char *mech = LDAP_SASL_SIMPLE;
736
735
  struct berval cred = {0, NULL};
737
736
  int v2v3 = LDAP_VERSION3;
738
 
  const char *binddn = NULL;
739
737
  const char *passwd = NULL;
740
738
#if defined(USE_OPENLDAP)
741
739
  char *ldapurl = NULL;
863
861
#endif /* !USE_OPENLDAP */
864
862
 
865
863
  if (mode & CLTAUTH) {
866
 
    mech = "EXTERNAL";
867
 
    binddn = "";
868
864
    passwd = NULL;
869
865
  } else {
870
 
    binddn = bufBindDN?bufBindDN:mctx.bindDN;
871
866
    passwd = bufPasswd?bufPasswd:mctx.passwd;
872
867
    if (passwd) {
873
868
      cred.bv_val = (char *)passwd;
991
986
     */
992
987
    if ((mod2 & M2_RANDOM_SASLAUTHID) && tttctx) {
993
988
      rnd (tttctx->buf2, mctx.sasl_authid_low, mctx.sasl_authid_high,
994
 
           mctx.sasl_authid_nbdigit);
 
989
           (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.sasl_authid_nbdigit);
995
990
      strncpy (&(tttctx->bufSaslAuthid[tttctx->startSaslAuthid]),
996
991
               tttctx->buf2, mctx.sasl_authid_nbdigit);
997
992
      my_saslauthid = tttctx->bufSaslAuthid;
1324
1319
          num = field->cnt;
1325
1320
          field->cnt++; /* Next value for next loop */
1326
1321
        }
1327
 
        sprintf (tttctx->buf2, "%0*d", field->nb, num);
 
1322
        sprintf (tttctx->buf2, "%0*d", (mctx.mod2 & M2_NOZEROPAD) ? 0 : field->nb, num);
1328
1323
        strcat (attrib->buf, tttctx->buf2);
1329
1324
        if (field->var != -1)
1330
1325
          strcpy (object->var[field->var], tttctx->buf2);
1347
1342
          num = field->cnt;
1348
1343
          field->cnt++; /* Next value for next loop */
1349
1344
        }
1350
 
        sprintf (tttctx->buf2, "%0*d", field->nb, num);
 
1345
        sprintf (tttctx->buf2, "%0*d", (mctx.mod2 & M2_NOZEROPAD) ? 0 : field->nb, num);
1351
1346
        strcat (attrib->buf, tttctx->buf2);
1352
1347
        if (field->var != -1)
1353
1348
          strcpy (object->var[field->var], tttctx->buf2);
1359
1354
          strcpy (object->var[field->var], field->dlf->str[num]);
1360
1355
        break;
1361
1356
      case HOW_RND_NUMBER:
1362
 
        rnd (tttctx->buf2, field->low, field->high, field->nb);
 
1357
        rnd (tttctx->buf2, field->low, field->high, (mctx.mod2 & M2_NOZEROPAD) ? 0 : field->nb);
1363
1358
        strcat (attrib->buf, tttctx->buf2);
1364
1359
        if (field->var != -1)
1365
1360
          strcpy (object->var[field->var], tttctx->buf2);
1430
1425
      (void) randomString (tttctx, mctx.baseDNNbDigit);
1431
1426
    else
1432
1427
      rnd (tttctx->buf2, mctx.baseDNLow, mctx.baseDNHigh,       /*JLS 14-11-00*/
1433
 
                                        mctx.baseDNNbDigit);    /*JLS 14-11-00*/
 
1428
           (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.baseDNNbDigit);        /*JLS 14-11-00*/
1434
1429
    strncpy (&(tttctx->bufBaseDN[tttctx->startBaseDN]), 
1435
1430
                        tttctx->buf2, mctx.baseDNNbDigit);
1436
1431
    if (mctx.mode & VERY_VERBOSE)
1481
1476
        (void) randomString (tttctx, mctx.randomNbDigit);
1482
1477
      else
1483
1478
        rnd (tttctx->buf2, mctx.randomLow, mctx.randomHigh,     /*JLS 14-11-00*/
1484
 
                        mctx.randomNbDigit);                    /*JLS 14-11-00*/
 
1479
             (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.randomNbDigit);                      /*JLS 14-11-00*/
1485
1480
      strncpy (&(tttctx->bufFilter[tttctx->startRandom]), 
1486
 
                        tttctx->buf2, mctx.randomNbDigit);
 
1481
               tttctx->buf2, mctx.randomNbDigit);
 
1482
      if ((mctx.mod2 & M2_NOZEROPAD) && mctx.randomTail) {
 
1483
        strcat(tttctx->bufFilter, mctx.randomTail);
 
1484
      }
1487
1485
      if (mctx.mode & VERY_VERBOSE)
1488
1486
        printf ("ldclt[%d]: %s: random mode:filter=\"%s\"\n",
1489
1487
                 mctx.pid, tttctx->thrdId, tttctx->bufFilter);
1492
1490
    {
1493
1491
      if (mctx.mode & COMMON_COUNTER)                           /*JLS 14-03-01*/
1494
1492
      {                                                         /*JLS 14-03-01*/
1495
 
        int      val;                                           /*JLS 14-03-01*/
1496
 
        val = incrementCommonCounter (tttctx);                  /*JLS 14-03-01*/
 
1493
        int val = incrementCommonCounter (tttctx);                      /*JLS 14-03-01*/
1497
1494
        if (val == -1)                                          /*JLS 14-03-01*/
1498
1495
          return (-1);                                          /*JLS 14-03-01*/
1499
 
        sprintf (tttctx->buf2, "%0*d", mctx.randomNbDigit, val);/*JLS 14-03-01*/
 
1496
        sprintf (tttctx->buf2, "%0*d", (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.randomNbDigit, val);/*JLS 14-03-01*/
1500
1497
      }                                                         /*JLS 14-03-01*/
1501
 
      else                                                      /*JLS 14-03-01*/
1502
 
      {                                                         /*JLS 14-03-01*/
1503
 
        tttctx->lastVal++;
1504
 
        if (tttctx->lastVal > mctx.randomHigh)
1505
 
        {
1506
 
          if (!(mctx.mode & NOLOOP))
1507
 
            tttctx->lastVal = mctx.randomLow;
1508
 
          else
1509
 
          {
1510
 
            /*
1511
 
             * Well, there is no clean way to exit. Let's use the error
1512
 
             * condition and hope all will be ok.
1513
 
             */
1514
 
            printf ("ldclt[%d]: %s: Hit top incrementeal value\n",
1515
 
                     mctx.pid, tttctx->thrdId);
1516
 
            return (-1);
1517
 
          }
1518
 
        }
1519
 
        sprintf (tttctx->buf2, "%0*d", mctx.randomNbDigit, tttctx->lastVal);
 
1498
      else if ((mctx.mode & NOLOOP) && ((tttctx->lastVal + mctx.incr) > mctx.randomHigh))
 
1499
      {
 
1500
        /*
 
1501
         * Well, there is no clean way to exit. Let's use the error
 
1502
         * condition and hope all will be ok.
 
1503
         */
 
1504
        printf ("ldclt[%d]: %s: Hit top incremental value %d > %d\n",
 
1505
                 mctx.pid, tttctx->thrdId, (tttctx->lastVal + mctx.incr), mctx.randomHigh);
 
1506
        return (-1);
 
1507
      }
 
1508
      else
 
1509
      {
 
1510
        tttctx->lastVal = incr_and_wrap(tttctx->lastVal, mctx.randomLow, mctx.randomHigh, mctx.incr);
 
1511
        sprintf (tttctx->buf2, "%0*d", (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.randomNbDigit, tttctx->lastVal);
1520
1512
      }                                                         /*JLS 14-03-01*/
1521
1513
 
1522
1514
      strncpy (&(tttctx->bufFilter[tttctx->startRandom]), tttctx->buf2,
1523
1515
                        mctx.randomNbDigit);
 
1516
      if ((mctx.mod2 & M2_NOZEROPAD) && mctx.randomTail) {
 
1517
        strcat(tttctx->bufFilter, mctx.randomTail);
 
1518
      }
1524
1519
      if (mctx.mode & VERY_VERBOSE)
1525
1520
        printf ("ldclt[%d]: %s: incremental mode:filter=\"%s\"\n",
1526
1521
                 mctx.pid, tttctx->thrdId, tttctx->bufFilter);
3919
3914
    }
3920
3915
    else
3921
3916
    { /* if search success & we are in verbose mode */
 
3917
      int nentries = 0;
3922
3918
      if (mctx.mode & VERBOSE)
3923
3919
      {
3924
3920
        for (e = ldap_first_message (tttctx->ldapCtx, res); e != NULL ; e = ldap_next_message (tttctx->ldapCtx, e) )
3928
3924
          {
3929
3925
            /* if this is an entry that returned */
3930
3926
            case LDAP_RES_SEARCH_ENTRY:
 
3927
              nentries++;
3931
3928
              /* get dereferenced value into resctrls:  deref parsing  */
3932
3929
              parse_rc = ldap_get_entry_controls ( tttctx->ldapCtx, e, &resctrls );
3933
3930
              if ( resctrls != NULL ) 
3975
3972
        } /*end of message retriving */
3976
3973
      } /* end of verbose mode */
3977
3974
 
 
3975
      if ((mctx.srch_nentries > -1) && (mctx.srch_nentries != nentries)) {
 
3976
        printf ("Error: search returned %d entries not the requested %d entries\n", nentries, mctx.srch_nentries);
 
3977
        goto bail;
 
3978
      }
 
3979
 
3978
3980
      if (incrementNbOpers (tttctx) < 0)/* Memorize operation */
3979
3981
      {
3980
3982
        goto bail;