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); 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 #ifdef ENABLE_TLS
static int vencrypt_send_version(struct nvnc_client* client) 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); enum rfb_vencrypt_subtype subtype = ntohl(*msg);
if (subtype != RFB_VENCRYPT_X509_PLAIN) { if (subtype != RFB_VENCRYPT_X509_PLAIN) {
send_byte(client, 0); // TODO Close after write client->state = VNC_CLIENT_STATE_ERROR;
stream_close(client->net_stream); send_byte_and_close(client, 0);
client_unref(client);
return sizeof(*msg); return sizeof(*msg);
} }
send_byte(client, 1); send_byte(client, 1);
if (stream_upgrade_to_tls(client->net_stream, client->server->tls_creds) < 0) { if (stream_upgrade_to_tls(client->net_stream, client->server->tls_creds) < 0) {
client->state = VNC_CLIENT_STATE_ERROR;
stream_close(client->net_stream); stream_close(client->net_stream);
client_unref(client); client_unref(client);
return sizeof(*msg); return sizeof(*msg);