From: Timo Sirainen Date: Tue, 6 Jul 2004 06:35:30 +0000 (+0300) Subject: Fixes, patch by Andrey Panin X-Git-Tag: 1.1.alpha1~3817 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb05765777cf968a7fb784602c310a8a418156a1;p=thirdparty%2Fdovecot%2Fcore.git Fixes, patch by Andrey Panin --HG-- branch : HEAD --- diff --git a/src/auth/mech-apop.c b/src/auth/mech-apop.c index 49305c977e..b8cdd3a1d9 100644 --- a/src/auth/mech-apop.c +++ b/src/auth/mech-apop.c @@ -10,7 +10,6 @@ */ #include "common.h" -#include "safe-memset.h" #include "mech.h" #include "passdb.h" #include "md5.h" @@ -40,14 +39,18 @@ apop_credentials_callback(const char *credentials, (struct apop_auth_request *)auth_request; unsigned char digest[16]; struct md5_context ctx; + int ret = FALSE; - md5_init(&ctx); - md5_update(&ctx, auth->challenge, strlen(auth->challenge)); - md5_update(&ctx, credentials, strlen(credentials)); - md5_final(&ctx, digest); + if (credentials != NULL) { + md5_init(&ctx); + md5_update(&ctx, auth->challenge, strlen(auth->challenge)); + md5_update(&ctx, credentials, strlen(credentials)); + md5_final(&ctx, digest); - mech_auth_finish(auth_request, NULL, 0, - memcmp(digest, auth->digest, 16) == 0); + ret = memcmp(digest, auth->digest, 16) == 0; + } + + mech_auth_finish(auth_request, NULL, 0, ret); } static int diff --git a/src/pop3-login/client.c b/src/pop3-login/client.c index c102129745..8c9f088601 100644 --- a/src/pop3-login/client.c +++ b/src/pop3-login/client.c @@ -225,14 +225,14 @@ static void client_destroy_oldest(void) } } -static char *get_apop_challenge(void) +static char *get_apop_challenge(struct pop3_client *client) { - struct auth_connect_id id; + struct auth_connect_id *id = &client->auth_id; - if (!auth_client_reserve_connection(auth_client, "APOP", &id)) + if (!auth_client_reserve_connection(auth_client, "APOP", id)) return NULL; - return i_strdup_printf("<%x.%x.%s@%s>", id.server_pid, id.connect_uid, + return i_strdup_printf("<%x.%x.%s@%s>", id->server_pid, id->connect_uid, dec2str(ioloop_time), my_hostname); } @@ -241,7 +241,7 @@ static void client_auth_ready(struct pop3_client *client) client->common.io = io_add(client->common.fd, IO_READ, client_input, client); - client->apop_challenge = get_apop_challenge(); + client->apop_challenge = get_apop_challenge(client); client_send_line(client, t_strconcat("+OK " PACKAGE " ready.", client->apop_challenge, NULL)); }