From 03dceaef9a6534b698d6e68bcae8747dd5215a0c Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Sat, 2 May 2026 13:05:21 -0700 Subject: [PATCH] thin: guard keyword-value pair decode against empty payload bytes Signed-off-by: SAY-5 --- src/oracledb/impl/thin/messages/base.pyx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/oracledb/impl/thin/messages/base.pyx b/src/oracledb/impl/thin/messages/base.pyx index a2ba5108..75327d5b 100644 --- a/src/oracledb/impl/thin/messages/base.pyx +++ b/src/oracledb/impl/thin/messages/base.pyx @@ -268,12 +268,20 @@ cdef class Message: if num_bytes > 0: binary_value = buf.read_bytes() buf.read_ub2(&keyword_num) # keyword num + # `text_value` and `binary_value` start as None and are assigned + # only when the corresponding length is non-zero. Some servers + # send keyword pairs with zero-length payloads (observed on + # ALTER PLUGGABLE DATABASE OPEN / CLOSE in 19c — #587), so guard + # the decode/use of each value before applying it. if keyword_num == TNS_KEYWORD_NUM_CURRENT_SCHEMA: - self.conn_impl._current_schema = text_value.decode() + if text_value is not None: + self.conn_impl._current_schema = text_value.decode() elif keyword_num == TNS_KEYWORD_NUM_EDITION: - self.conn_impl._edition = text_value.decode() + if text_value is not None: + self.conn_impl._edition = text_value.decode() elif keyword_num == TNS_KEYWORD_NUM_TRANSACTION_ID: - self._update_sessionless_txn_state(binary_value) + if binary_value is not None: + self._update_sessionless_txn_state(binary_value) cdef int _process_message(self, ReadBuffer buf, uint8_t message_type) except -1: