From 1827be0bd6a400f4b5970f5b37b1d2c8e83b6a3f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 19 Feb 2013 17:32:15 -0500 Subject: Make a parse_config_line_from_str variant that gives error messages Without this patch, there's no way to know what went wrong when we fail to parse a torrc line entirely (that is, we can't turn it into a K,V pair.) This patch introduces a new function that yields an error message on failure, so we can at least tell the user what to look for in their nonfunctional torrc. (Actually, it's the same function as before with a new name: parse_config_line_from_str is now a wrapper macro that the unit tests use.) Fixes bug 7950; fix on 0.2.0.16-alpha (58de695f9062576f) which first introduced the possibility of a torrc value not parsing correctly. --- src/or/confparse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/or') diff --git a/src/or/confparse.c b/src/or/confparse.c index 717d4ac2aa..98fde98e7d 100644 --- a/src/or/confparse.c +++ b/src/or/confparse.c @@ -91,12 +91,15 @@ config_get_lines(const char *string, config_line_t **result, int extended) { config_line_t *list = NULL, **next; char *k, *v; + const char *parse_err; next = &list; do { k = v = NULL; - string = parse_config_line_from_str(string, &k, &v); + string = parse_config_line_from_str_verbose(string, &k, &v, &parse_err); if (!string) { + log_warn(LD_CONFIG, "Error while parsing configuration: %s", + parse_err?parse_err:""); config_free_lines(list); tor_free(k); tor_free(v); -- cgit v1.2.3-54-g00ecf