server: Close after sending VeNCrypt failure message

vencrypt
Andri Yngvason 2020-01-25 16:04:04 +00:00
parent b30a5516d3
commit 547387f549
1 changed files with 9 additions and 3 deletions

View File

@ -201,6 +201,12 @@ static int send_byte(struct nvnc_client* client, uint8_t value)
return stream_write(client->net_stream, &value, 1, NULL, NULL);
}
static int send_byte_and_close(struct nvnc_client* client, uint8_t value)
{
return stream_write(client->net_stream, &value, 1, close_after_write,
client);
}
#ifdef ENABLE_TLS
static int vencrypt_send_version(struct nvnc_client* client)
{
@ -247,15 +253,15 @@ static int on_vencrypt_subtype_message(struct nvnc_client* client)
enum rfb_vencrypt_subtype subtype = ntohl(*msg);
if (subtype != RFB_VENCRYPT_X509_PLAIN) {
send_byte(client, 0); // TODO Close after write
stream_close(client->net_stream);
client_unref(client);
client->state = VNC_CLIENT_STATE_ERROR;
send_byte_and_close(client, 0);
return sizeof(*msg);
}
send_byte(client, 1);
if (stream_upgrade_to_tls(client->net_stream, client->server->tls_creds) < 0) {
client->state = VNC_CLIENT_STATE_ERROR;
stream_close(client->net_stream);
client_unref(client);
return sizeof(*msg);