|
|
|
@ -175,8 +175,7 @@ static rfbBool decompStreamInited = FALSE;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Separate buffer for compressed data. */
|
|
|
|
|
// TODO:
|
|
|
|
|
// #define ZLIB_BUFFER_SIZE 512
|
|
|
|
|
/* TODO: threading issues */
|
|
|
|
|
#define ZLIB_BUFFER_SIZE 30000
|
|
|
|
|
static char zlib_buffer[ZLIB_BUFFER_SIZE];
|
|
|
|
|
|
|
|
|
@ -205,6 +204,33 @@ ConnectToRFBServer(rfbClient* client,const char *hostname, int port)
|
|
|
|
|
{
|
|
|
|
|
unsigned int host;
|
|
|
|
|
|
|
|
|
|
if (client->serverPort==-1) {
|
|
|
|
|
/* serverHost is a file recorded by vncrec. */
|
|
|
|
|
const char* magic="vncLog0.0";
|
|
|
|
|
char buffer[10];
|
|
|
|
|
rfbVNCRec* rec = (rfbVNCRec*)malloc(sizeof(rfbVNCRec));
|
|
|
|
|
client->vncRec = rec;
|
|
|
|
|
|
|
|
|
|
rec->file = fopen(client->serverHost,"rb");
|
|
|
|
|
rec->tv.tv_sec = 0;
|
|
|
|
|
rec->readTimestamp = FALSE;
|
|
|
|
|
rec->doNotSleep = FALSE;
|
|
|
|
|
|
|
|
|
|
if (!rec->file) {
|
|
|
|
|
rfbClientLog("Could not open %s.\n",client->serverHost);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
setbuf(rec->file,0);
|
|
|
|
|
fread(buffer,1,strlen(magic),rec->file);
|
|
|
|
|
if (strncmp(buffer,magic,strlen(magic))) {
|
|
|
|
|
rfbClientLog("File %s was not recorded by vncrec.\n",client->serverHost);
|
|
|
|
|
fclose(rec->file);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
client->sock = 0;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!StringToIPAddr(hostname, &host)) {
|
|
|
|
|
rfbClientLog("Couldn't convert '%s' to host address\n", hostname);
|
|
|
|
|
return FALSE;
|
|
|
|
@ -289,25 +315,28 @@ InitialiseRFBConnection(rfbClient* client)
|
|
|
|
|
case rfbVncAuth:
|
|
|
|
|
if (!ReadFromRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;
|
|
|
|
|
|
|
|
|
|
if (client->GetPassword)
|
|
|
|
|
passwd = client->GetPassword(client);
|
|
|
|
|
if (client->serverPort!=-1) { /* if not playing a vncrec file */
|
|
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
if ((!passwd) || (strlen(passwd) == 0)) {
|
|
|
|
|
rfbClientLog("Reading password failed\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (strlen(passwd) > 8) {
|
|
|
|
|
passwd[8] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rfbEncryptBytes(challenge, passwd);
|
|
|
|
|
rfbEncryptBytes(challenge, passwd);
|
|
|
|
|
|
|
|
|
|
/* Lose the password from memory */
|
|
|
|
|
for (i = strlen(passwd); i >= 0; i--) {
|
|
|
|
|
passwd[i] = '\0';
|
|
|
|
|
}
|
|
|
|
|
/* 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;
|
|
|
|
|
if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ReadFromRFBServer(client, (char *)&authResult, 4)) return FALSE;
|
|
|
|
|
|
|
|
|
@ -638,6 +667,8 @@ HandleRFBServerMessage(rfbClient* client)
|
|
|
|
|
{
|
|
|
|
|
rfbServerToClientMsg msg;
|
|
|
|
|
|
|
|
|
|
if (client->serverPort==-1)
|
|
|
|
|
client->vncRec->readTimestamp = TRUE;
|
|
|
|
|
if (!ReadFromRFBServer(client, (char *)&msg, 1))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|