summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-08-01 14:37:07 -0400
committerNick Mathewson <nickm@torproject.org>2018-08-01 14:37:07 -0400
commiteab0d9242dd83c7525d0e7f9946fd0e71a01a342 (patch)
treedb492f5b4ef641ee802f0b0b1c9ea24f4636aa14
parent1c85b609d5e3c85c424800da508e80769474cb57 (diff)
parent861d690018c213ad017fbf8dc99d4790c111c396 (diff)
downloadtor-eab0d9242dd83c7525d0e7f9946fd0e71a01a342.tar.gz
tor-eab0d9242dd83c7525d0e7f9946fd0e71a01a342.zip
Merge branch 'maint-0.3.4' into release-0.3.4
-rw-r--r--src/test/test_config.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/test/test_config.c b/src/test/test_config.c
index 461aa646d6..8662b832b8 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -5536,6 +5536,12 @@ test_config_include_opened_file_list(void *data)
config_line_t *result = NULL;
smartlist_t *opened_files = smartlist_new();
+ char *torrcd = NULL;
+ char *subfolder = NULL;
+ char *path = NULL;
+ char *empty = NULL;
+ char *file = NULL;
+ char *dot = NULL;
char *dir = tor_strdup(get_fname("test_include_opened_file_list"));
tt_ptr_op(dir, OP_NE, NULL);
@@ -5545,8 +5551,7 @@ test_config_include_opened_file_list(void *data)
tt_int_op(mkdir(dir, 0700), OP_EQ, 0);
#endif
- char torrcd[PATH_MAX+1];
- tor_snprintf(torrcd, sizeof(torrcd), "%s"PATH_SEPARATOR"%s", dir, "torrc.d");
+ tor_asprintf(&torrcd, "%s"PATH_SEPARATOR"%s", dir, "torrc.d");
#ifdef _WIN32
tt_int_op(mkdir(torrcd), OP_EQ, 0);
@@ -5554,9 +5559,7 @@ test_config_include_opened_file_list(void *data)
tt_int_op(mkdir(torrcd, 0700), OP_EQ, 0);
#endif
- char subfolder[PATH_MAX+1];
- tor_snprintf(subfolder, sizeof(subfolder), "%s"PATH_SEPARATOR"%s", torrcd,
- "subfolder");
+ tor_asprintf(&subfolder, "%s"PATH_SEPARATOR"%s", torrcd, "subfolder");
#ifdef _WIN32
tt_int_op(mkdir(subfolder), OP_EQ, 0);
@@ -5564,21 +5567,17 @@ test_config_include_opened_file_list(void *data)
tt_int_op(mkdir(subfolder, 0700), OP_EQ, 0);
#endif
- char path[PATH_MAX+1];
- tor_snprintf(path, sizeof(path), "%s"PATH_SEPARATOR"%s", subfolder,
+ tor_asprintf(&path, "%s"PATH_SEPARATOR"%s", subfolder,
"01_file_in_subfolder");
tt_int_op(write_str_to_file(path, "Test 1\n", 0), OP_EQ, 0);
- char empty[PATH_MAX+1];
- tor_snprintf(empty, sizeof(empty), "%s"PATH_SEPARATOR"%s", torrcd, "empty");
+ tor_asprintf(&empty, "%s"PATH_SEPARATOR"%s", torrcd, "empty");
tt_int_op(write_str_to_file(empty, "", 0), OP_EQ, 0);
- char file[PATH_MAX+1];
- tor_snprintf(file, sizeof(file), "%s"PATH_SEPARATOR"%s", torrcd, "file");
+ tor_asprintf(&file, "%s"PATH_SEPARATOR"%s", torrcd, "file");
tt_int_op(write_str_to_file(file, "Test 2\n", 0), OP_EQ, 0);
- char dot[PATH_MAX+1];
- tor_snprintf(dot, sizeof(dot), "%s"PATH_SEPARATOR"%s", torrcd, ".dot");
+ tor_asprintf(&dot, "%s"PATH_SEPARATOR"%s", torrcd, ".dot");
tt_int_op(write_str_to_file(dot, "Test 3\n", 0), OP_EQ, 0);
char torrc_contents[1000];
@@ -5605,6 +5604,12 @@ test_config_include_opened_file_list(void *data)
SMARTLIST_FOREACH(opened_files, char *, f, tor_free(f));
smartlist_free(opened_files);
config_free_lines(result);
+ tor_free(torrcd);
+ tor_free(subfolder);
+ tor_free(path);
+ tor_free(empty);
+ tor_free(file);
+ tor_free(dot);
tor_free(dir);
}