[dovecot-cvs] dovecot/src/imap-login client.c,1.1,1.2
cras at procontrol.fi
cras at procontrol.fi
Sun Feb 2 09:10:48 EET 2003
Update of /home/cvs/dovecot/src/imap-login
In directory danu:/tmp/cvs-serv17045/imap-login
Modified Files:
client.c
Log Message:
STARTTLS commands crashed. imap-login STARTTLS also ignored next command.
Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap-login/client.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- client.c 28 Jan 2003 21:35:25 -0000 1.1
+++ client.c 2 Feb 2003 07:10:45 -0000 1.2
@@ -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;
More information about the dovecot-cvs
mailing list