diff options
author | Adam Tkac <atkac@redhat.com> | 2011-02-21 12:55:24 +0000 |
---|---|---|
committer | Adam Tkac <atkac@redhat.com> | 2011-02-21 12:55:24 +0000 |
commit | 7cb47d6b3cd25e1a22a0a3d09f045a54a577c23a (patch) | |
tree | 2e28de86a0e8e35fb0ad1254da6d5de219043313 /common | |
parent | 9c8076bf9b32b8dff38a85d87f43a10c6903babd (diff) | |
download | tigervnc-7cb47d6b3cd25e1a22a0a3d09f045a54a577c23a.tar.gz tigervnc-7cb47d6b3cd25e1a22a0a3d09f045a54a577c23a.zip |
[Bugfix] Honor server security type order instead of client's when negotiating security type.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4300 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common')
-rw-r--r-- | common/rfb/CConnection.cxx | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx index cc68ea11..04e3439b 100644 --- a/common/rfb/CConnection.cxx +++ b/common/rfb/CConnection.cxx @@ -157,24 +157,23 @@ void CConnection::processSecurityTypesMsg() throwConnFailedException(); std::list<rdr::U8>::iterator j; - int secTypePos, secTypePosMin; - - secTypePosMin = secTypes.size(); for (int i = 0; i < nServerSecTypes; i++) { rdr::U8 serverSecType = is->readU8(); vlog.debug("Server offers security type %s(%d)", - secTypeName(serverSecType),serverSecType); - - // We keep trying types, to find the one that matches and - // which appears first in the client's list of supported types. - for (j = secTypes.begin(), secTypePos = 0; j != secTypes.end(); j++, secTypePos++) { - if (*j == serverSecType && secTypePos < secTypePosMin) { - secType = *j; - secTypePosMin = secTypePos; - break; - } - } + secTypeName(serverSecType), serverSecType); + + /* + * Use the first type sent by server which matches client's type. + * It means server's order specifies priority. + */ + if (secType == secTypeInvalid) { + for (j = secTypes.begin(); j != secTypes.end(); j++) + if (*j == serverSecType) { + secType = *j; + break; + } + } } // Inform the server of our decision |