Commit 3afc7a2b authored by Joel Martin's avatar Joel Martin

Issue #15 - rfb.js: wait for security type list.

Apparently the virtualbox VNC server send the size and then the
security type list in separate frames so we need to wait for the full
list.
parent 3cc74720
...@@ -678,6 +678,11 @@ init_msg = function() { ...@@ -678,6 +678,11 @@ init_msg = function() {
case 'Security' : case 'Security' :
if (rfb_version >= 3.7) { if (rfb_version >= 3.7) {
num_types = rQ[rQi++]; num_types = rQ[rQi++];
if (rQlen() < num_types) {
rQi--;
Util.Debug(" waiting for security types");
return;
}
if (num_types === 0) { if (num_types === 0) {
strlen = rQshift32(); strlen = rQshift32();
reason = rQshiftStr(strlen); reason = rQshiftStr(strlen);
...@@ -702,7 +707,7 @@ init_msg = function() { ...@@ -702,7 +707,7 @@ init_msg = function() {
send_array([rfb_auth_scheme]); send_array([rfb_auth_scheme]);
} else { } else {
if (rQlen() < 4) { if (rQlen() < 4) {
updateState('failed', "Invalid security frame"); Util.Debug(" waiting for security scheme bytes");
return; return;
} }
rfb_auth_scheme = rQshift32(); rfb_auth_scheme = rQshift32();
...@@ -717,7 +722,7 @@ init_msg = function() { ...@@ -717,7 +722,7 @@ init_msg = function() {
switch (rfb_auth_scheme) { switch (rfb_auth_scheme) {
case 0: // connection failed case 0: // connection failed
if (rQlen() < 4) { if (rQlen() < 4) {
//Util.Debug(" waiting for auth reason bytes"); Util.Debug(" waiting for auth reason bytes");
return; return;
} }
strlen = rQshift32(); strlen = rQshift32();
...@@ -734,7 +739,7 @@ init_msg = function() { ...@@ -734,7 +739,7 @@ init_msg = function() {
return; return;
} }
if (rQlen() < 16) { if (rQlen() < 16) {
//Util.Debug(" waiting for auth challenge bytes"); Util.Debug(" waiting for auth challenge bytes");
return; return;
} }
challenge = rQshiftBytes(16); challenge = rQshiftBytes(16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment