HandleVncAuth: revert asking for a password after 232bcad

Fixes #21
master
Mariusz Bialonczyk 2023-01-05 12:21:33 +01:00 committed by Andri Yngvason
parent 64449b249a
commit 2b9a886edd
1 changed files with 24 additions and 0 deletions

View File

@ -524,10 +524,34 @@ static rfbBool ReadSupportedSecurityType(rfbClient* client, uint32_t* result,
static rfbBool HandleVncAuth(rfbClient* client)
{
uint8_t challenge[CHALLENGESIZE];
char* passwd = NULL;
int i;
if (!ReadFromRFBServer(client, (char*)challenge, CHALLENGESIZE))
return FALSE;
if (client->GetPassword)
passwd = client->GetPassword(client);
if ((!passwd) || (strlen(passwd) == 0)) {
rfbClientLog("Reading password failed\n");
return FALSE;
}
if (strlen(passwd) > 8) {
passwd[8] = '\0';
}
rfbClientEncryptBytes(challenge, passwd);
/* Lose the password from memory */
for (i = strlen(passwd); i >= 0; i--) {
passwd[i] = '\0';
}
free(passwd);
if (!WriteToRFBServer(client, (char*)challenge, CHALLENGESIZE))
return FALSE;
/* Handle the SecurityResult message */
if (!rfbHandleAuthResult(client))
return FALSE;