Signed-off-by: Martin Koegler <mkoeg...@auto.tuwien.ac.at> --- common/rfb/CConnection.cxx | 30 ++++++++++++++---------------- common/rfb/CConnection.h | 8 -------- unix/vncviewer/CConn.cxx | 3 --- win/vncviewer/CConn.cxx | 2 -- 4 files changed, 14 insertions(+), 29 deletions(-)
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx index ac3c35e..21a1faa 100644 --- a/common/rfb/CConnection.cxx +++ b/common/rfb/CConnection.cxx @@ -33,7 +33,7 @@ static LogWriter vlog("CConnection"); CConnection::CConnection() : csecurity(0), is(0), os(0), reader_(0), writer_(0), - shared(false), nSecTypes(0), clientSecTypeOrder(false), + shared(false), clientSecTypeOrder(false), state_(RFBSTATE_UNINITIALISED), useProtocol3_3(false) { security = new Security(); @@ -59,13 +59,6 @@ void CConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_) os = os_; } -void CConnection::addSecType(rdr::U8 secType) -{ - if (nSecTypes == maxSecTypes) - throw Exception("too many security types"); - secTypes[nSecTypes++] = secType; -} - void CConnection::setClientSecTypeOrder(bool clientOrder) { clientSecTypeOrder = clientOrder; } @@ -133,6 +126,9 @@ void CConnection::processSecurityTypesMsg() int secType = secTypeInvalid; + std::list<rdr::U8> secTypes; + secTypes = security->GetEnabledSecTypes(); + if (cp.isVersion(3,3)) { // legacy 3.3 server may only offer "vnc authentication" or "none" @@ -142,10 +138,10 @@ void CConnection::processSecurityTypesMsg() throwConnFailedException(); } else if (secType == secTypeNone || secType == secTypeVncAuth) { - int j; - for (j = 0; j < nSecTypes; j++) - if (secTypes[j] == secType) break; - if (j == nSecTypes) + std::list<rdr::U8>::iterator i; + for (i = secTypes.begin(); i != secTypes.end(); i++) + if (*i == secType) break; + if (i == secTypes.end()) secType = secTypeInvalid; } else { vlog.error("Unknown 3.3 security type %d", secType); @@ -160,7 +156,7 @@ void CConnection::processSecurityTypesMsg() if (nServerSecTypes == 0) throwConnFailedException(); - int secTypePos = nSecTypes; + int secTypePos = secTypes.size(); for (int i = 0; i < nServerSecTypes; i++) { rdr::U8 serverSecType = is->readU8(); vlog.debug("Server offers security type %s(%d)", @@ -171,9 +167,11 @@ void CConnection::processSecurityTypesMsg() // we keep trying types, to find the one that matches and // which appears first in the client's list of supported types. if (secType == secTypeInvalid || clientSecTypeOrder) { - for (int j = 0; j < nSecTypes; j++) { - if (secTypes[j] == serverSecType && j < secTypePos) { - secType = secTypes[j]; + std::list<rdr::U8>::iterator i; + int j; + for (j = 0, i = secTypes.begin(); i != secTypes.end(); i++, j++) { + if (*i == serverSecType && j < secTypePos) { + secType = *i; secTypePos = j; break; } diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h index 6d3783a..832e061 100644 --- a/common/rfb/CConnection.h +++ b/common/rfb/CConnection.h @@ -59,11 +59,6 @@ namespace rfb { // (i.e. SConnection will not delete them). void setStreams(rdr::InStream* is, rdr::OutStream* os); - // addSecType() should be called once for each security type which the - // client supports. The order in which they're added is such that the - // first one is most preferred. - void addSecType(rdr::U8 secType); - // setClientSecTypeOrder() determines whether the client should obey // the server's security type preference, by picking the first server security // type that the client supports, or whether it should pick the first type @@ -163,9 +158,6 @@ namespace rfb { CMsgWriter* writer_; bool deleteStreamsWhenDone; bool shared; - enum { maxSecTypes = 8 }; - int nSecTypes; - rdr::U8 secTypes[maxSecTypes]; bool clientSecTypeOrder; stateEnum state_; diff --git a/unix/vncviewer/CConn.cxx b/unix/vncviewer/CConn.cxx index 406e167..8d311c3 100644 --- a/unix/vncviewer/CConn.cxx +++ b/unix/vncviewer/CConn.cxx @@ -69,9 +69,6 @@ CConn::CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_, menuKeysym = XStringToKeysym(menuKeyStr.buf); setShared(shared); - addSecType(secTypeNone); - addSecType(secTypeVncAuth); - addSecType(secTypeVeNCrypt); CSecurity::upg = this; /* Security instance is created in CConnection costructor. */ CharArray encStr(preferredEncoding.getData()); diff --git a/win/vncviewer/CConn.cxx b/win/vncviewer/CConn.cxx index 511c412..03fefdb 100644 --- a/win/vncviewer/CConn.cxx +++ b/win/vncviewer/CConn.cxx @@ -99,8 +99,6 @@ bool CConn::initialise(network::Socket* s, bool reverse) { applyOptions(options); // - Set which auth schemes we support, in order of preference - addSecType(secTypeVncAuth); - addSecType(secTypeNone); CSecurity::upg = this; // Start the RFB protocol -- 1.6.4.2 ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Tigervnc-devel mailing list Tigervnc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tigervnc-devel