Skip to content

Commit c27b32d

Browse files
The UUID returned by the database is not sufficiently unique so the
service name or SID must be used to ensure its uniqueness.
1 parent 950e0ea commit c27b32d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/oracledb/impl/thin/cookie.pyx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ cdef class ConnectionCookie:
4242

4343
cdef dict connection_cookies_by_uuid = {}
4444

45-
cdef ConnectionCookie get_connection_cookie_by_uuid(bytes uuid):
45+
cdef ConnectionCookie get_connection_cookie_by_uuid(bytes uuid,
46+
Description description):
4647
"""
4748
Returns a connection cookie given the UUID supplied in the accept packet.
4849
If no such cookie exists, a new one is created and returned for population.
4950
"""
50-
cdef ConnectionCookie cookie = connection_cookies_by_uuid.get(uuid)
51+
cdef:
52+
ConnectionCookie cookie
53+
str key_str
54+
bytes key
55+
key_str = description.service_name or description.sid or ""
56+
key = uuid + key_str.encode()
57+
cookie = connection_cookies_by_uuid.get(key)
5158
if cookie is None:
5259
cookie = ConnectionCookie.__new__(ConnectionCookie)
53-
connection_cookies_by_uuid[uuid] = cookie
60+
connection_cookies_by_uuid[key] = cookie
5461
return cookie

src/oracledb/impl/thin/messages.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,8 @@ cdef class ConnectMessage(Message):
17331733
if protocol_version >= TNS_VERSION_MIN_UUID:
17341734
buf.skip_raw_bytes(33)
17351735
db_uuid = buf.read_raw_bytes(16)[:16]
1736-
self.cookie = get_connection_cookie_by_uuid(db_uuid)
1736+
self.cookie = get_connection_cookie_by_uuid(db_uuid,
1737+
self.description)
17371738
buf._caps._adjust_for_protocol(protocol_version, protocol_options)
17381739
elif self.packet_type == TNS_PACKET_TYPE_REFUSE:
17391740
response = self.error_info.message

0 commit comments

Comments
 (0)