]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Properly hide all fields with passwords
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 15 Mar 2017 11:29:11 +0000 (13:29 +0200)
committerGitLab <gitlab@git.dovecot.net>
Thu, 16 Mar 2017 06:49:37 +0000 (08:49 +0200)
client reply line wasn't hiding all items
which contain 'pass' substring. This was
inconsistent behaviour since elsewhere this was done.

src/auth/auth-client-connection.c

index ebcbbd666c938459c008b1d15a3a2319377e1576..cfa0073f35a30b96ac1e7e1e1090ae8b7f64be31 100644 (file)
@@ -34,17 +34,31 @@ static struct auth_client_connection *auth_client_connections;
 
 static const char *reply_line_hide_pass(const char *line)
 {
+       string_t *newline;
        const char *p, *p2;
 
-       /* hide proxy reply password */
-       p = strstr(line, "\tpass=");
-       if (p == NULL)
+       if (strstr(line, "pass") == NULL)
                return line;
-       p += 6;
 
-       p2 = strchr(p, '\t');
-       return t_strconcat(t_strdup_until(line, p), PASSWORD_HIDDEN_STR,
-                          p2, NULL);
+       newline = t_str_new(strlen(line));
+
+       const char *const *fields = t_strsplit(line, "\t");
+
+       while(*fields != NULL) {
+               p = strstr(*fields, "pass");
+               p2 = strchr(*fields, '=');
+               if (p == NULL || p2 == NULL || p2 < p) {
+                       str_append(newline, *fields);
+               } else {
+                       /* include = */
+                       str_append_data(newline, *fields, (p2 - *fields)+1);
+                       str_append(newline, PASSWORD_HIDDEN_STR);
+               }
+               str_append_c(newline, '\t');
+               fields++;
+       }
+
+       return str_c(newline);
 }
 
 static void auth_client_send(struct auth_client_connection *conn,