~ubuntu-branches/debian/lenny/tor/lenny

« back to all changes in this revision

Viewing changes to src/or/config.c

  • Committer: Package Import Robot
  • Author(s): Peter Palfrader
  • Date: 2011-12-15 21:25:18 UTC
  • mfrom: (1.6.1) (6.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20111215212518-4eaqirobd1uhcmxb
Tags: 0.2.1.32-1
New upstream version, fixing a heap overflow bug related to Tor's
SOCKS code (CVE-2011-2778).

Show diffs side-by-side

added added

removed removed

Lines of Context:
829
829
{
830
830
  if (_version == NULL) {
831
831
    if (strlen(tor_svn_revision)) {
832
 
      size_t len = strlen(VERSION)+strlen(tor_svn_revision)+8;
 
832
      size_t len = strlen(VERSION)+strlen(tor_svn_revision)+16;
833
833
      _version = tor_malloc(len);
834
 
      tor_snprintf(_version, len, "%s (r%s)", VERSION, tor_svn_revision);
 
834
      tor_snprintf(_version, len, "%s (git-%s)", VERSION, tor_svn_revision);
835
835
    } else {
836
836
      _version = tor_strdup(VERSION);
837
837
    }
1269
1269
  or_options_t *options = get_options();
1270
1270
  int running_tor = options->command == CMD_RUN_TOR;
1271
1271
  char *msg;
 
1272
  const int transition_affects_workers =
 
1273
    old_options && options_transition_affects_workers(old_options, options);
1272
1274
 
1273
1275
  if (running_tor && !have_lockfile()) {
1274
1276
    if (try_locking(options, 1) < 0)
1319
1321
    finish_daemon(options->DataDirectory);
1320
1322
  }
1321
1323
 
 
1324
  /* We want to reinit keys as needed before we do much of anything else:
 
1325
     keys are important, and other things can depend on them. */
 
1326
  if (transition_affects_workers ||
 
1327
      (options->V3AuthoritativeDir && (!old_options ||
 
1328
                                       !old_options->V3AuthoritativeDir))) {
 
1329
    if (init_keys() < 0) {
 
1330
      log_warn(LD_BUG,"Error initializing keys; exiting");
 
1331
      return -1;
 
1332
    }
 
1333
  }
 
1334
 
1322
1335
  /* Write our PID to the PID file. If we do not have write permissions we
1323
1336
   * will log a warning */
1324
1337
  if (running_tor && options->PidFile)
1368
1381
      geoip_remove_old_clients(time(NULL)+(2*60*60));
1369
1382
    }
1370
1383
 
1371
 
    if (options_transition_affects_workers(old_options, options)) {
 
1384
    if (transition_affects_workers) {
1372
1385
      log_info(LD_GENERAL,
1373
1386
               "Worker-related options changed. Rotating workers.");
 
1387
 
1374
1388
      if (server_mode(options) && !server_mode(old_options)) {
1375
 
        if (init_keys() < 0) {
1376
 
          log_warn(LD_BUG,"Error initializing keys; exiting");
1377
 
          return -1;
1378
 
        }
1379
1389
        ip_address_changed(0);
1380
1390
        if (has_completed_circuit || !any_predicted_circuits(time(NULL)))
1381
1391
          inform_testing_reachability();
1387
1397
      if (dns_reset())
1388
1398
        return -1;
1389
1399
    }
1390
 
 
1391
 
    if (options->V3AuthoritativeDir && !old_options->V3AuthoritativeDir)
1392
 
      init_keys();
1393
1400
  }
1394
1401
 
1395
1402
  /* Maybe load geoip file */
2878
2885
    else if (!strcasecmp(string, "bridge"))
2879
2886
      *auth |= BRIDGE_AUTHORITY;
2880
2887
    else if (!strcasecmp(string, "hidserv"))
2881
 
      *auth |= HIDSERV_AUTHORITY;
 
2888
      log_warn(LD_CONFIG,
 
2889
               "PublishServerDescriptor hidserv is invalid. See "
 
2890
               "PublishHidServDescriptors.");
2882
2891
    else if (!strcasecmp(string, "") || !strcmp(string, "0"))
2883
2892
      /* no authority */;
2884
2893
    else
3368
3377
                           "RelayBandwidthBurst", msg) < 0)
3369
3378
    return -1;
3370
3379
 
 
3380
  if (options->RelayBandwidthRate && !options->RelayBandwidthBurst)
 
3381
    options->RelayBandwidthBurst = options->RelayBandwidthRate;
 
3382
  if (options->RelayBandwidthBurst && !options->RelayBandwidthRate)
 
3383
    options->RelayBandwidthRate = options->RelayBandwidthBurst;
 
3384
 
3371
3385
  if (server_mode(options)) {
3372
3386
    if (options->BandwidthRate < ROUTER_REQUIRED_MIN_BANDWIDTH) {
3373
3387
      r = tor_snprintf(buf, sizeof(buf),
3399
3413
    }
3400
3414
  }
3401
3415
 
3402
 
  if (options->RelayBandwidthRate && !options->RelayBandwidthBurst)
3403
 
    options->RelayBandwidthBurst = options->RelayBandwidthRate;
3404
 
 
3405
3416
  if (options->RelayBandwidthRate > options->RelayBandwidthBurst)
3406
3417
    REJECT("RelayBandwidthBurst must be at least equal "
3407
3418
           "to RelayBandwidthRate.");
3759
3770
                                       new_options->ServerDNSSearchDomains ||
3760
3771
      old_options->SafeLogging != new_options->SafeLogging ||
3761
3772
      old_options->ClientOnly != new_options->ClientOnly ||
 
3773
      public_server_mode(old_options) != public_server_mode(new_options) ||
3762
3774
      !config_lines_eq(old_options->Logs, new_options->Logs))
3763
3775
    return 1;
3764
3776
 
4621
4633
  switch (file_status(fname)) {
4622
4634
    case FN_FILE:
4623
4635
      old_val = read_file_to_str(fname, 0, NULL);
4624
 
      if (strcmpstart(old_val, GENERATED_FILE_PREFIX)) {
 
4636
      if (!old_val || strcmpstart(old_val, GENERATED_FILE_PREFIX)) {
4625
4637
        rename_old = 1;
4626
4638
      }
4627
4639
      tor_free(old_val);