Commit 1da223b0 1da223b05d0b851d6cb025af3d58f70e1c533d0a by Sergey Poznyakoff

Fix pop3d command parser (complement afda9ba4)

* pop3d/cmd.c (command_table_head): Remove.  Use command_table
instead.  All uses changed.
* pop3d/stls.c (pop3d_stls): Fail if TLS is not requested.
1 parent a6ed2f92
...@@ -20,8 +20,6 @@ struct mu_tls_config global_tls_conf; ...@@ -20,8 +20,6 @@ struct mu_tls_config global_tls_conf;
20 20
21 static struct pop3d_command command_table[] = { 21 static struct pop3d_command command_table[] = {
22 { "STLS", pop3d_stls }, 22 { "STLS", pop3d_stls },
23 #define COMMAND_TABLE_STLS 0
24 #define COMMAND_TABLE_PLAIN 1
25 { "RETR", pop3d_retr }, 23 { "RETR", pop3d_retr },
26 { "DELE", pop3d_dele }, 24 { "DELE", pop3d_dele },
27 { "USER", pop3d_user }, 25 { "USER", pop3d_user },
...@@ -38,13 +36,11 @@ static struct pop3d_command command_table[] = { ...@@ -38,13 +36,11 @@ static struct pop3d_command command_table[] = {
38 { NULL } 36 { NULL }
39 }; 37 };
40 38
41 static struct pop3d_command *command_table_head;
42
43 pop3d_command_handler_t 39 pop3d_command_handler_t
44 pop3d_find_command (const char *name) 40 pop3d_find_command (const char *name)
45 { 41 {
46 struct pop3d_command *p; 42 struct pop3d_command *p;
47 for (p = command_table_head; p->name; p++) 43 for (p = command_table; p->name; p++)
48 { 44 {
49 if (mu_c_strcasecmp (name, p->name) == 0) 45 if (mu_c_strcasecmp (name, p->name) == 0)
50 return p->handler; 46 return p->handler;
...@@ -137,11 +133,6 @@ stls_preflight (mu_m_server_t msrv) ...@@ -137,11 +133,6 @@ stls_preflight (mu_m_server_t msrv)
137 if (errors) 133 if (errors)
138 return 1; 134 return 1;
139 135
140 if (tls_requested)
141 command_table_head = command_table + COMMAND_TABLE_STLS;
142 else
143 command_table_head = command_table + COMMAND_TABLE_PLAIN;
144
145 return 0; 136 return 0;
146 } 137 }
147 138
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
22 int 22 int
23 pop3d_stls (char *arg, struct pop3d_session *session) 23 pop3d_stls (char *arg, struct pop3d_session *session)
24 { 24 {
25 if (session->tls_mode == tls_no)
26 return ERR_BAD_CMD;
27
25 if (strlen (arg) != 0) 28 if (strlen (arg) != 0)
26 return ERR_BAD_ARGS; 29 return ERR_BAD_ARGS;
27 30
......