From: Aki Tuomi Date: Wed, 22 Nov 2017 08:49:49 +0000 (+0200) Subject: auth: Check that key is not empty in passdb or userdb template X-Git-Tag: 2.3.0.rc1~416 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2bd58dc6e7c991c86713a4b91f9db468abe734a4;p=thirdparty%2Fdovecot%2Fcore.git auth: Check that key is not empty in passdb or userdb template Prevents nasty crash later on if template has 'key = value' dovecot: auth: Panic: file auth-request.c: line 1746 (auth_request_set_field): assertion failed: (*name != '\0') --- diff --git a/src/auth/passdb-template.c b/src/auth/passdb-template.c index a229af1fc7..ade424a6a5 100644 --- a/src/auth/passdb-template.c +++ b/src/auth/passdb-template.c @@ -27,6 +27,10 @@ struct passdb_template *passdb_template_build(pool_t pool, const char *args) else key = t_strdup_until(*tmp, value++); + if (*key == '\0') + i_fatal("Invalid passdb template %s - key must not be empty", + args); + key = p_strdup(pool, key); value = p_strdup(pool, value); array_append(&tmpl->args, &key, 1); diff --git a/src/auth/userdb-template.c b/src/auth/userdb-template.c index 71f1dd7418..1c1ce9c8ea 100644 --- a/src/auth/userdb-template.c +++ b/src/auth/userdb-template.c @@ -30,6 +30,11 @@ userdb_template_build(pool_t pool, const char *userdb_name, const char *args) else key = t_strdup_until(*tmp, value++); + + if (*key == '\0') + i_fatal("Invalid userdb template %s - key must not be empty", + args); + nonull_value = value == NULL ? "" : value; if (strcasecmp(key, "uid") == 0) { uid = userdb_parse_uid(NULL, nonull_value);