Skip to content

Commit 39cddf0

Browse files
Ensure that unsupported OSON versions raise an exception.
1 parent e1b206f commit 39cddf0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/oracledb/errors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
201201
ERR_TDS_TYPE_NOT_SUPPORTED = 3018
202202
ERR_OSON_NODE_TYPE_NOT_SUPPORTED = 3019
203203
ERR_OSON_FIELD_NAME_LIMITATION = 3020
204+
ERR_OSON_VERSION_NOT_SUPPORTED = 3021
204205

205206
# error numbers that result in DatabaseError
206207
ERR_TNS_ENTRY_NOT_FOUND = 4000
@@ -460,6 +461,8 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
460461
'OSON field names may not exceed 255 UTF-8 encoded bytes',
461462
ERR_OSON_NODE_TYPE_NOT_SUPPORTED:
462463
'OSON node type 0x{node_type:x} is not supported',
464+
ERR_OSON_VERSION_NOT_SUPPORTED:
465+
'OSON version {version} is not supported',
463466
ERR_POOL_HAS_BUSY_CONNECTIONS:
464467
'connection pool cannot be closed because connections are busy',
465468
ERR_POOL_NO_CONNECTION_AVAILABLE:

src/oracledb/impl/thin/oson.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ cdef class OsonDecoder(Buffer):
252252
ptr[2] != TNS_JSON_MAGIC_BYTE_3:
253253
errors._raise_err(errors.ERR_UNEXPECTED_DATA, data=ptr[:3])
254254
self.read_ub1(&version)
255+
if version != TNS_JSON_VERSION:
256+
errors._raise_err(errors.ERR_OSON_VERSION_NOT_SUPPORTED,
257+
version=version)
255258
self.read_uint16(&self.flags)
256259

257260
# if value is a scalar value, the header is much smaller

0 commit comments

Comments
 (0)