Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2690:7b50711a168d HEAD
Use the library function for username string sanitization.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 05 Oct 2004 18:30:03 +0300 |
parents | 631611c2d6e6 |
children | 46f879c46b45 |
files | src/auth/mech.c |
diffstat | 1 files changed, 4 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/mech.c Tue Oct 05 18:29:38 2004 +0300 +++ b/src/auth/mech.c Tue Oct 05 18:30:03 2004 +0300 @@ -6,6 +6,7 @@ #include "hash.h" #include "mech.h" #include "str.h" +#include "str-sanitize.h" #include "var-expand.h" #include "auth-client-connection.h" #include "auth-master-connection.h" @@ -335,7 +336,7 @@ const char *get_log_prefix(const struct auth_request *auth_request) { #define MAX_LOG_USERNAME_LEN 64 - const char *p, *ip; + const char *ip; string_t *str; str = t_str_new(64); @@ -343,25 +344,8 @@ if (auth_request->user == NULL) str_append(str, "?"); else { - /* any control characters in username will be replaced by '?' */ - for (p = auth_request->user; *p != '\0'; p++) { - if ((unsigned char)*p < 32) - break; - } - - str_append_n(str, auth_request->user, - (size_t)(p - auth_request->user)); - for (; *p != '\0'; p++) { - if ((unsigned char)*p < 32) - str_append_c(str, '?'); - else - str_append_c(str, *p); - } - - if (str_len(str) > MAX_LOG_USERNAME_LEN) { - str_truncate(str, MAX_LOG_USERNAME_LEN); - str_append(str, "..."); - } + str_sanitize_append(str, auth_request->user, + MAX_LOG_USERNAME_LEN); } ip = net_ip2addr(&auth_request->remote_ip);