aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/CSecurityVeNCrypt.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb/CSecurityVeNCrypt.cxx')
-rw-r--r--common/rfb/CSecurityVeNCrypt.cxx44
1 files changed, 24 insertions, 20 deletions
diff --git a/common/rfb/CSecurityVeNCrypt.cxx b/common/rfb/CSecurityVeNCrypt.cxx
index 22201dd2..98dad494 100644
--- a/common/rfb/CSecurityVeNCrypt.cxx
+++ b/common/rfb/CSecurityVeNCrypt.cxx
@@ -51,7 +51,6 @@ CSecurityVeNCrypt::CSecurityVeNCrypt(CConnection* cc, SecurityClient* sec)
chosenType = secTypeVeNCrypt;
nAvailableTypes = 0;
availableTypes = NULL;
- iAvailableType = 0;
}
CSecurityVeNCrypt::~CSecurityVeNCrypt()
@@ -64,16 +63,20 @@ bool CSecurityVeNCrypt::processMsg()
{
InStream* is = cc->getInStream();
OutStream* os = cc->getOutStream();
-
+
/* get major, minor versions, send what we can support (or 0.0 for can't support it) */
if (!haveRecvdMajorVersion) {
+ if (!is->hasData(1))
+ return false;
+
majorVersion = is->readU8();
haveRecvdMajorVersion = true;
-
- return false;
}
if (!haveRecvdMinorVersion) {
+ if (!is->hasData(1))
+ return false;
+
minorVersion = is->readU8();
haveRecvdMinorVersion = true;
}
@@ -100,47 +103,48 @@ bool CSecurityVeNCrypt::processMsg()
}
haveSentVersion = true;
- return false;
}
/* Check that the server is OK */
if (!haveAgreedVersion) {
+ if (!is->hasData(1))
+ return false;
+
if (is->readU8())
throw AuthFailureException("The server reported it could not support the "
"VeNCrypt version");
haveAgreedVersion = true;
- return false;
}
/* get a number of types */
if (!haveNumberOfTypes) {
+ if (!is->hasData(1))
+ return false;
+
nAvailableTypes = is->readU8();
- iAvailableType = 0;
if (!nAvailableTypes)
throw AuthFailureException("The server reported no VeNCrypt sub-types");
availableTypes = new rdr::U32[nAvailableTypes];
haveNumberOfTypes = true;
- return false;
}
if (nAvailableTypes) {
/* read in the types possible */
if (!haveListOfTypes) {
- if (is->checkNoWait(4)) {
- availableTypes[iAvailableType++] = is->readU32();
- haveListOfTypes = (iAvailableType >= nAvailableTypes);
- vlog.debug("Server offers security type %s (%d)",
- secTypeName(availableTypes[iAvailableType - 1]),
- availableTypes[iAvailableType - 1]);
-
- if (!haveListOfTypes)
- return false;
-
- } else
- return false;
+ if (!is->hasData(4 * nAvailableTypes))
+ return false;
+
+ for (int i = 0;i < nAvailableTypes;i++) {
+ availableTypes[i] = is->readU32();
+ vlog.debug("Server offers security type %s (%d)",
+ secTypeName(availableTypes[i]),
+ availableTypes[i]);
+ }
+
+ haveListOfTypes = true;
}
/* make a choice and send it to the server, meanwhile set up the stack */