]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Give more verbose protocol level errors + some fixes.
authorTimo Sirainen <tss@iki.fi>
Wed, 4 Jun 2003 16:35:11 +0000 (19:35 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 4 Jun 2003 16:35:11 +0000 (19:35 +0300)
--HG--
branch : HEAD

src/imap/client.c
src/imap/cmd-fetch.c
src/imap/cmd-list.c
src/imap/cmd-store.c

index af0eb872d14a596ccb381ab0719dbfd7d6e3390e..85ca4138149478e2be5f6b3a6343075e1cdf7251 100644 (file)
@@ -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 {
index 5171213306a295612f0fece7de710a8638c2db39..2dc87499cc10dbf31f144a1acfb986fde48d6515 100644 (file)
@@ -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;
        }
 
index 6d0d901ab6d745ab39eef138306c3a262bede30d..a19cf1624ed0ef073ad1a1ed26071871bd4cc3d0 100644 (file)
@@ -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;
        }
 
index faf6bba7803e3105659845c7d53d55ceff18b672..328d9fd4d902dabee3d19e5b5439b95904b0db21 100644 (file)
@@ -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;
        }