From f0a6ae9394d6cf1abcbc43ac54eddffdf7938fb8 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Wed, 9 May 2018 10:19:02 +0300 Subject: [PATCH] config: Fix crash in doveconf -n when hiding sensitive information Broken by fc02343f --- src/config/doveconf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 873a3cb24b..625a3aaaa9 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -209,8 +209,10 @@ hide_secrets_from_value(struct ostream *output, const char *key, ptr++; len = (size_t)(ptr-optr); if (quote) { - o_stream_nsend_str(output, - str_nescape(optr, len)); + string_t *quoted = t_str_new(len*2); + str_append_escaped(quoted, optr, len); + o_stream_nsend(output, + quoted->data, quoted->used); } else { o_stream_nsend(output, optr, len); } @@ -228,11 +230,11 @@ hide_secrets_from_value(struct ostream *output, const char *key, Skip forward to avoid infinite loop. */ ptr++; } - } + }; /* if we are dealing with output, send rest here */ if (ret) { if (quote) - o_stream_nsend_str(output, str_escape(ptr)); + o_stream_nsend_str(output, str_escape(optr)); else o_stream_nsend_str(output, optr); }