summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Samuels <richard.l.samuels@gmail.com>2020-07-22 10:18:15 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-23 17:29:38 +0000
commit6e554668a820530cdf79360e4be1851e4cde2905 (patch)
tree79023775d54c9069a02ded09a36ba5f0f97bd5a4
parentf7413c92e510170f8c2b06c64c217aaebd0f5fd6 (diff)
downloadmongo-6e554668a820530cdf79360e4be1851e4cde2905.tar.gz
SERVER-43055 Prevent exceptions when lldb prints a BSONObj with datetimes beyond datetime.MAXYEAR
-rw-r--r--buildscripts/lldb/lldb_printers.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/buildscripts/lldb/lldb_printers.py b/buildscripts/lldb/lldb_printers.py
index 34be8b3876f..8989dbfca2e 100644
--- a/buildscripts/lldb/lldb_printers.py
+++ b/buildscripts/lldb/lldb_printers.py
@@ -90,8 +90,11 @@ def BSONObjPrinter(valobj, *_args): # pylint: disable=invalid-name
size = struct.unpack("<I", valobj.GetProcess().ReadMemory(ptr, 4, lldb.SBError()))[0]
if size < 5 or size > 17 * 1024 * 1024:
return None
- buf = bson.BSON(bytes(valobj.GetProcess().ReadMemory(ptr, size, lldb.SBError())))
- buf_str = buf.decode()
+ mem = bytes(memoryview(valobj.GetProcess().ReadMemory(ptr, size, lldb.SBError())))
+ if not bson.is_valid(mem):
+ return None
+
+ buf_str = bson.decode(mem)
obj = json_util.dumps(buf_str, indent=4)
# If the object is huge then just dump it as one line
if obj.count("\n") > 1000: