Ticket #26873: tor_path_max.patch

File tor_path_max.patch, 2.7 KB (added by paulusASol, 10 months ago)

Patch proposal

  • src/test/test_config.c

    diff --git a/src/test/test_config.c b/src/test/test_config.c
    index f5c759402..907e3a1fb 100644
    a b test_config_include_opened_file_list(void *data) 
    56005600
    56015601  config_line_t *result = NULL;
    56025602  smartlist_t *opened_files = smartlist_new();
     5603  char *torrcd = NULL;
     5604  char *subfolder = NULL;
     5605  char *path = NULL;
     5606  char *empty = NULL;
     5607  char *file = NULL;
     5608  char *dot = NULL;
    56035609  char *dir = tor_strdup(get_fname("test_include_opened_file_list"));
    56045610  tt_ptr_op(dir, OP_NE, NULL);
    56055611
    test_config_include_opened_file_list(void *data) 
    56095615  tt_int_op(mkdir(dir, 0700), OP_EQ, 0);
    56105616#endif
    56115617
    5612   char torrcd[PATH_MAX+1];
    5613   tor_snprintf(torrcd, sizeof(torrcd), "%s"PATH_SEPARATOR"%s", dir, "torrc.d");
     5618  tor_asprintf(&torrcd, "%s"PATH_SEPARATOR"%s", dir, "torrc.d");
    56145619
    56155620#ifdef _WIN32
    56165621  tt_int_op(mkdir(torrcd), OP_EQ, 0);
    test_config_include_opened_file_list(void *data) 
    56185623  tt_int_op(mkdir(torrcd, 0700), OP_EQ, 0);
    56195624#endif
    56205625
    5621   char subfolder[PATH_MAX+1];
    5622   tor_snprintf(subfolder, sizeof(subfolder), "%s"PATH_SEPARATOR"%s", torrcd,
    5623                "subfolder");
     5626  tor_asprintf(&subfolder, "%s"PATH_SEPARATOR"%s", torrcd, "subfolder");
    56245627
    56255628#ifdef _WIN32
    56265629  tt_int_op(mkdir(subfolder), OP_EQ, 0);
    test_config_include_opened_file_list(void *data) 
    56285631  tt_int_op(mkdir(subfolder, 0700), OP_EQ, 0);
    56295632#endif
    56305633
    5631   char path[PATH_MAX+1];
    5632   tor_snprintf(path, sizeof(path), "%s"PATH_SEPARATOR"%s", subfolder,
     5634  tor_asprintf(&path, "%s"PATH_SEPARATOR"%s", subfolder,
    56335635               "01_file_in_subfolder");
    56345636  tt_int_op(write_str_to_file(path, "Test 1\n", 0), OP_EQ, 0);
    56355637
    5636   char empty[PATH_MAX+1];
    5637   tor_snprintf(empty, sizeof(empty), "%s"PATH_SEPARATOR"%s", torrcd, "empty");
     5638  tor_asprintf(&empty, "%s"PATH_SEPARATOR"%s", torrcd, "empty");
    56385639  tt_int_op(write_str_to_file(empty, "", 0), OP_EQ, 0);
    56395640
    5640   char file[PATH_MAX+1];
    5641   tor_snprintf(file, sizeof(file), "%s"PATH_SEPARATOR"%s", torrcd, "file");
     5641  tor_asprintf(&file, "%s"PATH_SEPARATOR"%s", torrcd, "file");
    56425642  tt_int_op(write_str_to_file(file, "Test 2\n", 0), OP_EQ, 0);
    56435643
    5644   char dot[PATH_MAX+1];
    5645   tor_snprintf(dot, sizeof(dot), "%s"PATH_SEPARATOR"%s", torrcd, ".dot");
     5644  tor_asprintf(&dot, "%s"PATH_SEPARATOR"%s", torrcd, ".dot");
    56465645  tt_int_op(write_str_to_file(dot, "Test 3\n", 0), OP_EQ, 0);
    56475646
    56485647  char torrc_contents[1000];
    test_config_include_opened_file_list(void *data) 
    56695668  SMARTLIST_FOREACH(opened_files, char *, f, tor_free(f));
    56705669  smartlist_free(opened_files);
    56715670  config_free_lines(result);
     5671  tor_free(torrcd);
     5672  tor_free(subfolder);
     5673  tor_free(path);
     5674  tor_free(empty);
     5675  tor_free(file);
     5676  tor_free(dot);
    56725677  tor_free(dir);
    56735678}
    56745679