From: Timo Sirainen Date: Wed, 4 Jun 2003 16:35:11 +0000 (+0300) Subject: Give more verbose protocol level errors + some fixes. X-Git-Tag: 1.1.alpha1~4568 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2820b44812b2da7f3b172bb3521b623a3f84f2b;p=thirdparty%2Fdovecot%2Fcore.git Give more verbose protocol level errors + some fixes. --HG-- branch : HEAD --- diff --git a/src/imap/client.c b/src/imap/client.c index af0eb872d1..85ca413814 100644 --- a/src/imap/client.c +++ b/src/imap/client.c @@ -143,7 +143,7 @@ void client_send_tagline(struct client *client, const char *data) void client_send_command_error(struct client *client, const char *msg) { - const char *error; + const char *error, *cmd; int fatal; if (msg == NULL) { @@ -153,7 +153,16 @@ void client_send_command_error(struct client *client, const char *msg) return; } } - error = t_strconcat("BAD Error in IMAP command: ", msg, NULL); + + if (client->cmd_tag == NULL) + error = t_strconcat("BAD Error in IMAP tag: ", msg, NULL); + else if (client->cmd_name == NULL) + error = t_strconcat("BAD Error in IMAP command: ", msg, NULL); + else { + cmd = str_ucase(t_strdup_noconst(client->cmd_name)); + error = t_strconcat("BAD Error in IMAP command ", + cmd, ": ", msg, NULL); + } client->cmd_error = TRUE; client_send_tagline(client, error); @@ -242,11 +251,12 @@ static int client_skip_line(struct client *client) for (i = 0; i < data_size; i++) { if (data[i] == '\n') { client->input_skip_line = FALSE; - i_stream_skip(client->input, i+1); + i++; break; } } + i_stream_skip(client->input, i); return !client->input_skip_line; } @@ -296,8 +306,7 @@ static int client_handle_input(struct client *client) if (client->cmd_func == NULL) { /* unknown command */ - client_send_command_error(client, t_strconcat( - "Unknown command '", client->cmd_name, "'", NULL)); + client_send_command_error(client, "Unknown command."); client->input_skip_line = TRUE; _client_reset_command(client); } else { diff --git a/src/imap/cmd-fetch.c b/src/imap/cmd-fetch.c index 5171213306..2dc87499cc 100644 --- a/src/imap/cmd-fetch.c +++ b/src/imap/cmd-fetch.c @@ -324,7 +324,7 @@ int cmd_fetch(struct client *client) messageset = imap_arg_string(&args[0]); if (messageset == NULL || (args[1].type != IMAP_ARG_LIST && args[1].type != IMAP_ARG_ATOM)) { - client_send_command_error(client, "Invalid FETCH arguments."); + client_send_command_error(client, "Invalid arguments."); return TRUE; } diff --git a/src/imap/cmd-list.c b/src/imap/cmd-list.c index 6d0d901ab6..a19cf1624e 100644 --- a/src/imap/cmd-list.c +++ b/src/imap/cmd-list.c @@ -304,7 +304,7 @@ int _cmd_list_full(struct client *client, int lsub) mask = imap_arg_string(&args[1]); if (ref == NULL || mask == NULL) { - client_send_command_error(client, "Invalid FETCH arguments."); + client_send_command_error(client, "Invalid arguments."); return TRUE; } diff --git a/src/imap/cmd-store.c b/src/imap/cmd-store.c index faf6bba780..328d9fd4d9 100644 --- a/src/imap/cmd-store.c +++ b/src/imap/cmd-store.c @@ -51,7 +51,7 @@ int cmd_store(struct client *client) item = imap_arg_string(&args[1]); if (messageset == NULL || item == NULL) { - client_send_command_error(client, "Invalid STORE arguments."); + client_send_command_error(client, "Invalid arguments."); return TRUE; }