Mercurial > dovecot > core-2.2
comparison src/director/login-connection.c @ 20693:fa67f1a329da
Fix control flow and T_BEGIN/T_END hygiene
You mustn't goto, break, continue, or return from out of a
T_BEGIN {...} T_END block, as that will lose a t_pop().
This has been seen in the wild: Panic: Leaked t_pop() call
Signed-off-by: Phil Carmody <phil@dovecot.fi>
author | Phil Carmody <phil@dovecot.fi> |
---|---|
date | Wed, 31 Aug 2016 20:14:41 +0300 |
parents | 0f22db71df7a |
children | 59437f8764c6 |
comparison
equal
deleted
inserted
replaced
20692:914bc37e32bf | 20693:fa67f1a329da |
---|---|
71 o_stream_nsend(output, buf, ret); | 71 o_stream_nsend(output, buf, ret); |
72 } | 72 } |
73 | 73 |
74 static void login_connection_authreply_input(struct login_connection *conn) | 74 static void login_connection_authreply_input(struct login_connection *conn) |
75 { | 75 { |
76 bool bail = FALSE; | |
76 const char *line; | 77 const char *line; |
77 | 78 |
78 while ((line = i_stream_read_next_line(conn->input)) != NULL) T_BEGIN { | 79 while (!bail && (line = i_stream_read_next_line(conn->input)) != NULL) T_BEGIN { |
79 if (!conn->handshaked) { | 80 if (!conn->handshaked) { |
80 if (!version_string_verify(line, "director-authreply-client", | 81 if (!version_string_verify(line, "director-authreply-client", |
81 AUTHREPLY_PROTOCOL_MAJOR_VERSION)) { | 82 AUTHREPLY_PROTOCOL_MAJOR_VERSION)) { |
82 i_error("authreply client sent invalid handshake: %s", line); | 83 i_error("authreply client sent invalid handshake: %s", line); |
83 login_connection_deinit(&conn); | 84 login_connection_deinit(&conn); |
84 return; | 85 bail = TRUE; /* don't return from within a T_BEGIN {...} T_END */ |
86 } else { | |
87 conn->handshaked = TRUE; | |
85 } | 88 } |
86 conn->handshaked = TRUE; | |
87 } else { | 89 } else { |
88 auth_input_line(line, conn); | 90 auth_input_line(line, conn); |
89 } | 91 } |
90 } T_END; | 92 } T_END; |
93 | |
94 if (bail) | |
95 return; | |
96 | |
91 if (conn->input->eof) { | 97 if (conn->input->eof) { |
92 if (conn->input->stream_errno != 0 && | 98 if (conn->input->stream_errno != 0 && |
93 conn->input->stream_errno != ECONNRESET) { | 99 conn->input->stream_errno != ECONNRESET) { |
94 i_error("read(authreply connection) failed: %s", | 100 i_error("read(authreply connection) failed: %s", |
95 i_stream_get_error(conn->input)); | 101 i_stream_get_error(conn->input)); |