server: Send the proper reason string on security handshake failure
parent
1687b8c701
commit
b30a5516d3
12
src/server.c
12
src/server.c
|
@ -166,7 +166,8 @@ static int on_version_message(struct nvnc_client* client)
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_invalid_security_type(struct nvnc_client* client)
|
static int security_handshake_failed(struct nvnc_client* client,
|
||||||
|
const char* reason_string)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
|
@ -177,8 +178,6 @@ static int handle_invalid_security_type(struct nvnc_client* client)
|
||||||
struct rfb_error_reason* reason =
|
struct rfb_error_reason* reason =
|
||||||
(struct rfb_error_reason*)(buffer + sizeof(*result));
|
(struct rfb_error_reason*)(buffer + sizeof(*result));
|
||||||
|
|
||||||
static const char reason_string[] = "Unsupported security type\n";
|
|
||||||
|
|
||||||
*result = htonl(RFB_SECURITY_HANDSHAKE_FAILED);
|
*result = htonl(RFB_SECURITY_HANDSHAKE_FAILED);
|
||||||
reason->length = htonl(strlen(reason_string));
|
reason->length = htonl(strlen(reason_string));
|
||||||
(void)strcmp(reason->message, reason_string);
|
(void)strcmp(reason->message, reason_string);
|
||||||
|
@ -222,8 +221,7 @@ static int on_vencrypt_version_message(struct nvnc_client* client)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (msg->major != 0 || msg->minor != 2) {
|
if (msg->major != 0 || msg->minor != 2) {
|
||||||
// TODO: Say unsupported vencrypt type in message
|
security_handshake_failed(client, "Unsupported VeNCrypt version");
|
||||||
handle_invalid_security_type(client);
|
|
||||||
return sizeof(*msg);
|
return sizeof(*msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +297,7 @@ static int on_vencrypt_plain_auth_message(struct nvnc_client* client)
|
||||||
client->state = VNC_CLIENT_STATE_WAITING_FOR_INIT;
|
client->state = VNC_CLIENT_STATE_WAITING_FOR_INIT;
|
||||||
} else {
|
} else {
|
||||||
log_debug("User \"%s\" rejected\n", username);
|
log_debug("User \"%s\" rejected\n", username);
|
||||||
handle_invalid_security_type(client); // TODO say wrong auth
|
security_handshake_failed(client, "Invalid username or password");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sizeof(*msg) + ulen + plen;
|
return sizeof(*msg) + ulen + plen;
|
||||||
|
@ -325,7 +323,7 @@ static int on_security_message(struct nvnc_client* client)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
handle_invalid_security_type(client);
|
security_handshake_failed(client, "Unsupported security type");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue