Added tcp_ui_run() to prevent ui_select() push data on transport

which corrupts the stream and prevents a SSL reconnect to work.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1720 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Henrik Andersson 2013-06-20 12:51:27 +00:00
parent dc3be1486d
commit e6b10f6bcb
3 changed files with 23 additions and 15 deletions

View File

@ -227,6 +227,7 @@ RD_BOOL tcp_is_connected(void);
void tcp_reset_state(void); void tcp_reset_state(void);
RD_BOOL tcp_tls_connect(void); RD_BOOL tcp_tls_connect(void);
RD_BOOL tcp_tls_get_server_pubkey(STREAM s); RD_BOOL tcp_tls_get_server_pubkey(STREAM s);
void tcp_run_ui(RD_BOOL run);
/* asn.c */ /* asn.c */
RD_BOOL ber_in_header(STREAM s, int *tagval, int *length); RD_BOOL ber_in_header(STREAM s, int *tagval, int *length);

View File

@ -1121,8 +1121,6 @@ main(int argc, char *argv[])
continue; continue;
} }
g_network_error = False;
/* By setting encryption to False here, we have an encrypted login /* By setting encryption to False here, we have an encrypted login
packet but unencrypted transfer of other packets */ packet but unencrypted transfer of other packets */
@ -1140,13 +1138,16 @@ main(int argc, char *argv[])
return EX_OSERR; return EX_OSERR;
} }
tcp_run_ui(True);
g_redirect = False; g_redirect = False;
g_reconnect_loop = False; g_reconnect_loop = False;
rdp_main_loop(&deactivated, &ext_disc_reason); rdp_main_loop(&deactivated, &ext_disc_reason);
tcp_run_ui(False);
DEBUG(("Disconnecting...\n")); DEBUG(("Disconnecting...\n"));
if (!tcp_is_connected()) rdp_disconnect();
rdp_disconnect();
if (g_redirect) if (g_redirect)
continue; continue;

28
tcp.c
View File

@ -61,6 +61,7 @@ static RD_BOOL g_ssl_initialized = False;
static SSL *g_ssl = NULL; static SSL *g_ssl = NULL;
static SSL_CTX *g_ssl_ctx = NULL; static SSL_CTX *g_ssl_ctx = NULL;
static int g_sock; static int g_sock;
static RD_BOOL g_run_ui = False;
static struct stream g_in; static struct stream g_in;
static struct stream g_out[STREAM_COUNT]; static struct stream g_out[STREAM_COUNT];
int g_tcp_port_rdp = TCP_PORT_RDP; int g_tcp_port_rdp = TCP_PORT_RDP;
@ -123,7 +124,7 @@ tcp_send(STREAM s)
int length = s->end - s->data; int length = s->end - s->data;
int sent, total = 0; int sent, total = 0;
if (g_network_error) if (g_network_error == True)
return; return;
#ifdef WITH_SCARD #ifdef WITH_SCARD
@ -148,8 +149,6 @@ tcp_send(STREAM s)
#ifdef WITH_SCARD #ifdef WITH_SCARD
scard_unlock(SCARD_LOCK_TCP); scard_unlock(SCARD_LOCK_TCP);
#endif #endif
if (g_network_error == True)
return;
error("SSL_write: %d (%s)\n", ssl_err, TCP_STRERROR); error("SSL_write: %d (%s)\n", ssl_err, TCP_STRERROR);
g_network_error = True; g_network_error = True;
@ -172,8 +171,6 @@ tcp_send(STREAM s)
#ifdef WITH_SCARD #ifdef WITH_SCARD
scard_unlock(SCARD_LOCK_TCP); scard_unlock(SCARD_LOCK_TCP);
#endif #endif
if (g_network_error == True)
return;
error("send: %s\n", TCP_STRERROR); error("send: %s\n", TCP_STRERROR);
g_network_error = True; g_network_error = True;
@ -195,8 +192,8 @@ tcp_recv(STREAM s, uint32 length)
uint32 new_length, end_offset, p_offset; uint32 new_length, end_offset, p_offset;
int rcvd = 0, ssl_err; int rcvd = 0, ssl_err;
if (g_network_error) if (g_network_error == True)
return NULL; return;
if (s == NULL) if (s == NULL)
{ {
@ -226,11 +223,14 @@ tcp_recv(STREAM s, uint32 length)
while (length > 0) while (length > 0)
{ {
if ((!g_ssl || SSL_pending(g_ssl) <= 0) && !ui_select(g_sock)) if ((!g_ssl || SSL_pending(g_ssl) <= 0) && g_run_ui)
{ {
/* User quit */ if (!ui_select(g_sock))
g_user_quit = True; {
return NULL; /* User quit */
g_user_quit = True;
return NULL;
}
} }
if (g_ssl) if (g_ssl)
@ -603,3 +603,9 @@ tcp_reset_state(void)
g_out[i].channel_hdr = NULL; g_out[i].channel_hdr = NULL;
} }
} }
void
tcp_run_ui(RD_BOOL run)
{
g_run_ui = run;
}