[dovecot-cvs] dovecot/src/imap client.c,1.22,1.23 client.h,1.8,1.9 cmd-append.c,1.21,1.22 commands-util.c,1.18,1.19
cras at procontrol.fi
cras at procontrol.fi
Thu Jan 23 05:28:48 EET 2003
Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv25892/imap
Modified Files:
client.c client.h cmd-append.c commands-util.c
Log Message:
Disconnect client if given non-sync literal size is too large. Better than
eating the input.
Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- client.c 22 Jan 2003 19:23:28 -0000 1.22
+++ client.c 23 Jan 2003 03:28:46 -0000 1.23
@@ -45,9 +45,8 @@
{
struct client *client = context;
- client_send_line(my_client, "* BYE Disconnected for inactivity "
- "while waiting for command data.");
- o_stream_close(client->output);
+ client_disconnect_with_error(client,
+ "Disconnected for inactivity while waiting for command data.");
}
struct client *client_create(int hin, int hout, struct mail_storage *storage)
@@ -112,6 +111,12 @@
o_stream_close(client->output);
}
+void client_disconnect_with_error(struct client *client, const char *msg)
+{
+ client_send_line(client, t_strconcat("* BYE ", msg, NULL));
+ client_disconnect(client);
+}
+
void client_send_line(struct client *client, const char *data)
{
if (client->output->closed)
@@ -140,18 +145,23 @@
void client_send_command_error(struct client *client, const char *msg)
{
const char *error;
+ int fatal;
- if (msg == NULL)
- msg = imap_parser_get_error(client->parser);
+ if (msg == NULL) {
+ msg = imap_parser_get_error(client->parser, &fatal);
+ if (fatal) {
+ client_disconnect_with_error(client, msg);
+ return;
+ }
+ }
error = t_strconcat("BAD Error in IMAP command: ", msg, NULL);
client->cmd_error = TRUE;
client_send_tagline(client, error);
if (++client->bad_counter >= CLIENT_MAX_BAD_COMMANDS) {
- client_send_line(client,
- "* BYE Too many invalid IMAP commands.");
- client_disconnect(client);
+ client_disconnect_with_error(client,
+ "Too many invalid IMAP commands.");
}
}
Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- client.h 21 Jan 2003 05:37:35 -0000 1.8
+++ client.h 23 Jan 2003 03:28:46 -0000 1.9
@@ -41,6 +41,7 @@
/* Disconnect client connection */
void client_disconnect(struct client *client);
+void client_disconnect_with_error(struct client *client, const char *msg);
/* Send a line of data to client */
void client_send_line(struct client *client, const char *data);
Index: cmd-append.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-append.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- cmd-append.c 23 Jan 2003 03:17:09 -0000 1.21
+++ cmd-append.c 23 Jan 2003 03:28:46 -0000 1.22
@@ -51,10 +51,10 @@
struct imap_arg_list *flags_list;
struct mail_full_flags flags;
time_t internal_date;
- const char *mailbox, *internal_date_str;
+ const char *mailbox, *internal_date_str, *error;
uoff_t msg_size;
unsigned int count;
- int ret, failed, timezone_offset, nonsync;
+ int ret, failed, timezone_offset, nonsync, fatal_error;
/* <mailbox> */
if (!client_read_string_args(client, 1, &mailbox))
@@ -94,8 +94,15 @@
if (ret >= 0)
break;
if (ret == -1) {
- client_send_command_error(client,
- imap_parser_get_error(save_parser));
+ error = imap_parser_get_error(save_parser,
+ &fatal_error);
+ if (fatal_error) {
+ client_disconnect_with_error(client,
+ error);
+ } else {
+ client_send_command_error(client,
+ error);
+ }
break;
}
Index: commands-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/commands-util.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- commands-util.c 22 Jan 2003 20:46:36 -0000 1.18
+++ commands-util.c 23 Jan 2003 03:28:46 -0000 1.19
@@ -110,9 +110,8 @@
if (client->mailbox != NULL &&
client->mailbox->is_inconsistency_error(client->mailbox)) {
/* we can't do forced CLOSE, so have to disconnect */
- client_send_line(client, "* BYE Mailbox is in inconsistent "
- "state, please relogin.");
- client_disconnect(client);
+ client_disconnect_with_error(client,
+ "Mailbox is in inconsistent state, please relogin.");
return;
}
More information about the dovecot-cvs
mailing list