aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-11-01 14:30:30 +1000
committerteor <teor@torproject.org>2019-11-05 11:01:28 +1000
commitf29de4b8d2097676f9d2f067c176b38a08362046 (patch)
tree80e7c78a3059851cc744f433cba4b8c33905f860 /src/lib
parent5d85c247e8d28726402eaa51eb0e48ea7a1b6d7b (diff)
downloadtor-f29de4b8d2097676f9d2f067c176b38a08362046.tar.gz
tor-f29de4b8d2097676f9d2f067c176b38a08362046.zip
confmgt: Stop adding a space, when there is no option value
Fixes bug 32352; bugfix on 0.0.9pre6.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/confmgt/confmgt.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/confmgt/confmgt.c b/src/lib/confmgt/confmgt.c
index 1218a63ae3..3fdb630e8a 100644
--- a/src/lib/confmgt/confmgt.c
+++ b/src/lib/confmgt/confmgt.c
@@ -1307,9 +1307,10 @@ config_dump(const config_mgr_t *mgr, const void *default_options,
*/
continue;
}
- smartlist_add_asprintf(elements, "%s%s %s\n",
+ int value_exists = line->value && *(line->value);
+ smartlist_add_asprintf(elements, "%s%s%s%s\n",
comment_option ? "# " : "",
- line->key, line->value);
+ line->key, value_exists ? " " : "", line->value);
}
config_free_lines(assigned);
} SMARTLIST_FOREACH_END(mv);
@@ -1317,7 +1318,9 @@ config_dump(const config_mgr_t *mgr, const void *default_options,
if (fmt->extra) {
line = *(config_line_t**)STRUCT_VAR_P(options, fmt->extra->offset);
for (; line; line = line->next) {
- smartlist_add_asprintf(elements, "%s %s\n", line->key, line->value);
+ int value_exists = line->value && *(line->value);
+ smartlist_add_asprintf(elements, "%s%s%s\n",
+ line->key, value_exists ? " " : "", line->value);
}
}