The UUID returned by the database is not sufficiently unique so the

service name or SID must be used to ensure its uniqueness.
This commit is contained in:
Anthony Tuininga 2023-08-07 13:40:11 -06:00
parent 950e0eadb1
commit c27b32d51a
2 changed files with 12 additions and 4 deletions

View File

@ -42,13 +42,20 @@ cdef class ConnectionCookie:
cdef dict connection_cookies_by_uuid = {}
cdef ConnectionCookie get_connection_cookie_by_uuid(bytes uuid):
cdef ConnectionCookie get_connection_cookie_by_uuid(bytes uuid,
Description description):
"""
Returns a connection cookie given the UUID supplied in the accept packet.
If no such cookie exists, a new one is created and returned for population.
"""
cdef ConnectionCookie cookie = connection_cookies_by_uuid.get(uuid)
cdef:
ConnectionCookie cookie
str key_str
bytes key
key_str = description.service_name or description.sid or ""
key = uuid + key_str.encode()
cookie = connection_cookies_by_uuid.get(key)
if cookie is None:
cookie = ConnectionCookie.__new__(ConnectionCookie)
connection_cookies_by_uuid[uuid] = cookie
connection_cookies_by_uuid[key] = cookie
return cookie

View File

@ -1733,7 +1733,8 @@ cdef class ConnectMessage(Message):
if protocol_version >= TNS_VERSION_MIN_UUID:
buf.skip_raw_bytes(33)
db_uuid = buf.read_raw_bytes(16)[:16]
self.cookie = get_connection_cookie_by_uuid(db_uuid)
self.cookie = get_connection_cookie_by_uuid(db_uuid,
self.description)
buf._caps._adjust_for_protocol(protocol_version, protocol_options)
elif self.packet_type == TNS_PACKET_TYPE_REFUSE:
response = self.error_info.message