Mercurial > dovecot > core-2.2
changeset 1079:3aece07f3a1b HEAD
STARTTLS commands crashed. imap-login STARTTLS also ignored next command.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 02 Feb 2003 09:10:45 +0200 |
parents | 58ec36002730 |
children | 6def98421f46 |
files | src/imap-login/client.c src/pop3-login/client.c |
diffstat | 2 files changed, 48 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap-login/client.c Sun Feb 02 02:32:21 2003 +0200 +++ b/src/imap-login/client.c Sun Feb 02 09:10:45 2003 +0200 @@ -17,6 +17,8 @@ /* max. size of one parameter in line */ #define MAX_INBUF_SIZE 512 +#define MAX_OUTBUF_SIZE 1024 + /* max. number of IMAP argument elements to accept. The maximum memory usage for command from user is around MAX_INBUF_SIZE * MAX_IMAP_ARG_ELEMENTS */ #define MAX_IMAP_ARG_ELEMENTS 4 @@ -50,6 +52,36 @@ host)); } +static void client_open_streams(struct imap_client *client, int fd) +{ + client->input = i_stream_create_file(fd, default_pool, + MAX_INBUF_SIZE, FALSE); + client->output = o_stream_create_file(fd, default_pool, MAX_OUTBUF_SIZE, + IO_PRIORITY_DEFAULT, FALSE); + client->parser = imap_parser_create(client->input, client->output, + MAX_INBUF_SIZE, + MAX_IMAP_ARG_ELEMENTS); +} + +/* Skip incoming data until newline is found, + returns TRUE if newline was found. */ +static int client_skip_line(struct imap_client *client) +{ + const unsigned char *data; + size_t i, data_size; + + data = i_stream_get_data(client->input, &data_size); + + for (i = 0; i < data_size; i++) { + if (data[i] == '\n') { + i_stream_skip(client->input, i+1); + return TRUE; + } + } + + return FALSE; +} + static int cmd_capability(struct imap_client *client) { const char *capability; @@ -94,16 +126,16 @@ client->tls = TRUE; client_set_title(client); + /* we skipped it already, so don't ignore next command */ + client->skip_line = FALSE; + client->common.fd = fd_ssl; i_stream_unref(client->input); o_stream_unref(client->output); + imap_parser_destroy(client->parser); - client->input = i_stream_create_file(fd_ssl, default_pool, - 8192, FALSE); - client->output = o_stream_create_file(fd_ssl, default_pool, - 1024, IO_PRIORITY_DEFAULT, - FALSE); + client_open_streams(client, fd_ssl); } else { client_send_line(client, " * BYE TLS handehake failed."); client_destroy(client, "TLS handshake failed"); @@ -147,25 +179,6 @@ return FALSE; } -/* Skip incoming data until newline is found, - returns TRUE if newline was found. */ -static int client_skip_line(struct imap_client *client) -{ - const unsigned char *data; - size_t i, data_size; - - data = i_stream_get_data(client->input, &data_size); - - for (i = 0; i < data_size; i++) { - if (data[i] == '\n') { - i_stream_skip(client->input, i+1); - return TRUE; - } - } - - return FALSE; -} - static void client_handle_input(struct imap_client *client) { struct imap_arg *args; @@ -327,14 +340,9 @@ client->common.ip = *ip; client->common.fd = fd; + + client_open_streams(client, fd); client->io = io_add(fd, IO_READ, client_input, client); - client->input = i_stream_create_file(fd, default_pool, - MAX_INBUF_SIZE, FALSE); - client->output = o_stream_create_file(fd, default_pool, 1024, - IO_PRIORITY_DEFAULT, FALSE); - client->parser = imap_parser_create(client->input, client->output, - MAX_INBUF_SIZE, - MAX_IMAP_ARG_ELEMENTS); client->plain_login = buffer_create_dynamic(system_pool, 128, 8192); client->last_input = ioloop_time;
--- a/src/pop3-login/client.c Sun Feb 02 02:32:21 2003 +0200 +++ b/src/pop3-login/client.c Sun Feb 02 09:10:45 2003 +0200 @@ -45,6 +45,13 @@ host)); } +static void client_open_streams(struct pop3_client *client, int fd) +{ + client->input = i_stream_create_file(fd, default_pool, 8192, FALSE); + client->output = o_stream_create_file(fd, default_pool, 1024, + IO_PRIORITY_DEFAULT, FALSE); +} + static int cmd_stls(struct pop3_client *client) { int fd_ssl; @@ -79,11 +86,7 @@ i_stream_unref(client->input); o_stream_unref(client->output); - client->input = i_stream_create_file(fd_ssl, default_pool, - 8192, FALSE); - client->output = o_stream_create_file(fd_ssl, default_pool, - 1024, IO_PRIORITY_DEFAULT, - FALSE); + client_open_streams(client, fd_ssl); } else { client_send_line(client, "-ERR TLS handehake failed."); client_destroy(client, "TLS handshake failed"); @@ -238,9 +241,7 @@ client->common.ip = *ip; client->common.fd = fd; client->io = io_add(fd, IO_READ, client_input, client); - client->input = i_stream_create_file(fd, default_pool, 8192, FALSE); - client->output = o_stream_create_file(fd, default_pool, 1024, - IO_PRIORITY_DEFAULT, FALSE); + client_open_streams(client, fd); client->plain_login = buffer_create_dynamic(system_pool, 128, 8192); client->last_input = ioloop_time;