summaryrefslogtreecommitdiff
path: root/src/test/test_config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-05-19 15:50:27 -0400
committerNick Mathewson <nickm@torproject.org>2017-05-19 15:50:29 -0400
commit13034e1574bf5ee8c7bacba2c1c19a4a8adc8de8 (patch)
tree925f55ed8702a82a4799b14a71530a698bee139f /src/test/test_config.c
parent19615bce64cd381a925bc3910120ac39ca918e7c (diff)
downloadtor-13034e1574bf5ee8c7bacba2c1c19a4a8adc8de8.tar.gz
tor-13034e1574bf5ee8c7bacba2c1c19a4a8adc8de8.zip
Try another approach to fixing the bug in the #1922 test.
This isn't elegant, but it seems to be the best way around all of the issues involved in escaping and quoting that we've gotten into over the years.
Diffstat (limited to 'src/test/test_config.c')
-rw-r--r--src/test/test_config.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/test/test_config.c b/src/test/test_config.c
index 80579eaa91..eaf7e0d935 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -5164,6 +5164,8 @@ test_config_include_path_syntax(void *data)
config_line_t *result = NULL;
char *dir = tor_strdup(get_fname("test_include_path_syntax"));
+ char *esc_dir = NULL, *dir_with_pathsep = NULL,
+ *esc_dir_with_pathsep = NULL, *torrc_contents = NULL;
tt_ptr_op(dir, OP_NE, NULL);
#ifdef _WIN32
@@ -5172,18 +5174,18 @@ test_config_include_path_syntax(void *data)
tt_int_op(mkdir(dir, 0700), OP_EQ, 0);
#endif
-#ifdef _WIN32
-#define ESCAPED_PATH_SEPARATOR "\\" PATH_SEPARATOR
-#else
-#define ESCAPED_PATH_SEPARATOR PATH_SEPARATOR
-#endif
- char torrc_contents[1000];
- tor_snprintf(torrc_contents, sizeof(torrc_contents),
- "%%include \"%s\"\n"
- "%%include %s"PATH_SEPARATOR"\n"
- "%%include \"%s"ESCAPED_PATH_SEPARATOR"\"\n",
- dir, dir, dir);
+ esc_dir = esc_for_log(dir);
+ tor_asprintf(&dir_with_pathsep, "%s%s", dir, PATH_SEPARATOR);
+ esc_dir_with_pathsep = esc_for_log(dir_with_pathsep);
+
+ tor_asprintf(&torrc_contents,
+ "%%include %s\n"
+ "%%include %s%s \n" // space to avoid suppressing newline
+ "%%include %s\n",
+ esc_dir,
+ dir, PATH_SEPARATOR,
+ esc_dir_with_pathsep);
int include_used;
tt_int_op(config_get_lines_include(torrc_contents, &result, 0,&include_used),
@@ -5194,6 +5196,10 @@ test_config_include_path_syntax(void *data)
done:
config_free_lines(result);
tor_free(dir);
+ tor_free(torrc_contents);
+ tor_free(esc_dir);
+ tor_free(dir_with_pathsep);
+ tor_free(esc_dir_with_pathsep);
}
static void