Merge branch 'master' into PYTHON-5366
This commit is contained in:
commit
a2ddf1eb5b
@ -2281,7 +2281,7 @@ static PyObject* get_value(PyObject* self, PyObject* name, const char* buffer,
|
||||
}
|
||||
memcpy(&length, buffer + *position, 4);
|
||||
length = BSON_UINT32_FROM_LE(length);
|
||||
if (max < length) {
|
||||
if (max - 5 < length) { // Account for 5-byte header. max >= 5 guaranteed above
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
|
||||
@ -876,8 +876,6 @@ class TestViews(AsyncEncryptionIntegrationTest):
|
||||
|
||||
|
||||
class TestCorpus(AsyncEncryptionIntegrationTest):
|
||||
# PYTHON-5708: Encryption tests sending large payloads fail on some mongocryptd versions.
|
||||
@async_client_context.require_version_max(6, 99)
|
||||
@unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set")
|
||||
async def asyncSetUp(self):
|
||||
await super().asyncSetUp()
|
||||
@ -1054,8 +1052,6 @@ class TestBsonSizeBatches(AsyncEncryptionIntegrationTest):
|
||||
client_encrypted: AsyncMongoClient
|
||||
listener: OvertCommandListener
|
||||
|
||||
# PYTHON-5708: Encryption tests sending large payloads fail on some mongocryptd versions.
|
||||
@async_client_context.require_version_max(6, 99)
|
||||
async def asyncSetUp(self):
|
||||
await super().asyncSetUp()
|
||||
db = async_client_context.client.db
|
||||
|
||||
@ -1269,6 +1269,22 @@ class TestBSON(unittest.TestCase):
|
||||
encode(doc)
|
||||
self.assertEqual(cm.exception.document, doc)
|
||||
|
||||
def test_binary_length_accounts_for_header(self):
|
||||
size = 20
|
||||
binary_length = 12 # 5 more than the actual 7 bytes
|
||||
|
||||
payload = b""
|
||||
payload += struct.pack("<i", size) # document size
|
||||
payload += b"\x05" # type = Binary
|
||||
payload += b"a\x00" # key "a"
|
||||
payload += struct.pack("<I", binary_length) # Binary length (inflated)
|
||||
payload += b"\x00" # subtype 0
|
||||
payload += b"\x41" * 7 # value
|
||||
payload += b"\x00" # EOO
|
||||
|
||||
with self.assertRaises(InvalidBSON):
|
||||
decode(payload)
|
||||
|
||||
|
||||
class TestCodecOptions(unittest.TestCase):
|
||||
def test_document_class(self):
|
||||
|
||||
@ -872,8 +872,6 @@ class TestViews(EncryptionIntegrationTest):
|
||||
|
||||
|
||||
class TestCorpus(EncryptionIntegrationTest):
|
||||
# PYTHON-5708: Encryption tests sending large payloads fail on some mongocryptd versions.
|
||||
@client_context.require_version_max(6, 99)
|
||||
@unittest.skipUnless(any(AWS_CREDS.values()), "AWS environment credentials are not set")
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
@ -1050,8 +1048,6 @@ class TestBsonSizeBatches(EncryptionIntegrationTest):
|
||||
client_encrypted: MongoClient
|
||||
listener: OvertCommandListener
|
||||
|
||||
# PYTHON-5708: Encryption tests sending large payloads fail on some mongocryptd versions.
|
||||
@client_context.require_version_max(6, 99)
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
db = client_context.client.db
|
||||
|
||||
Loading…
Reference in New Issue
Block a user