Skip to content

Commit

Permalink
doveconf: Use key_ends_with to compare suffixes
Browse files Browse the repository at this point in the history
Fixes key hiding.

Broken in 1518e08
  • Loading branch information
cmouse committed Aug 14, 2018
1 parent 63a74b9 commit 970d829
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/config/doveconf.c
Expand Up @@ -239,15 +239,23 @@ hide_url_userpart_from_value(struct ostream *output, const char **_ptr,
return TRUE;
}

static inline bool key_ends_with(const char *key, const char *eptr,
const char *suffix)
{
/* take = into account */
size_t n = strlen(suffix)+1;
return (eptr-key > (ptrdiff_t)n && str_begins(eptr-n, suffix));
}

static bool
hide_secrets_from_value(struct ostream *output, const char *key,
const char *value)
{
bool ret = FALSE, quote = value_need_quote(value);
const char *ptr, *optr, *secret;
if (*value != '\0' &&
((value-key > 8 && str_begins(value-9, "_password")) ||
(value-key > 7 && str_begins(value-8, "_api_key")) ||
(key_ends_with(key, value, "_password") ||
key_ends_with(key, value, "_api_key") ||
str_begins(key, "ssl_key") ||
str_begins(key, "ssl_dh"))) {
o_stream_nsend_str(output, "# hidden, use -P to show it");
Expand Down

0 comments on commit 970d829

Please sign in to comment.