summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-pymongo/CVE-2024-5629.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-pymongo/CVE-2024-5629.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-pymongo/CVE-2024-5629.patch49
1 files changed, 49 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-pymongo/CVE-2024-5629.patch b/meta-python/recipes-devtools/python/python3-pymongo/CVE-2024-5629.patch
new file mode 100644
index 0000000000..0b0822a756
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pymongo/CVE-2024-5629.patch
@@ -0,0 +1,49 @@
1From a9454ae060fffa609cc02b129441679b7d248d8f Mon Sep 17 00:00:00 2001
2From: Shane Harvey <shnhrv@gmail.com>
3Date: Wed, 27 Mar 2024 16:51:23 -0700
4Subject: [PATCH] PYTHON-4305 Fix bson size check (#1564)
5
6CVE: CVE-2024-5629
7Upstream-Status: Backport [https://github.com/mongodb/mongo-python-driver/commit/372b5d68d5a57ccc43b33407cd23f0bc79d99283]
8Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
9---
10 bson/_cbsonmodule.c | 11 +++++------
11 1 file changed, 5 insertions(+), 6 deletions(-)
12
13diff --git a/bson/_cbsonmodule.c b/bson/_cbsonmodule.c
14index 1a296db..73370e2 100644
15--- a/bson/_cbsonmodule.c
16+++ b/bson/_cbsonmodule.c
17@@ -2052,6 +2052,7 @@ static PyObject* get_value(PyObject* self, PyObject* name, const char* buffer,
18 uint32_t c_w_s_size;
19 uint32_t code_size;
20 uint32_t scope_size;
21+ uint32_t len;
22 PyObject* code;
23 PyObject* scope;
24 PyObject* code_type;
25@@ -2071,7 +2072,8 @@ static PyObject* get_value(PyObject* self, PyObject* name, const char* buffer,
26 memcpy(&code_size, buffer + *position, 4);
27 code_size = BSON_UINT32_FROM_LE(code_size);
28 /* code_w_scope length + code length + code + scope length */
29- if (!code_size || max < code_size || max < 4 + 4 + code_size + 4) {
30+ len = 4 + 4 + code_size + 4;
31+ if (!code_size || max < code_size || max < len || len < code_size) {
32 goto invalid;
33 }
34 *position += 4;
35@@ -2089,12 +2091,9 @@ static PyObject* get_value(PyObject* self, PyObject* name, const char* buffer,
36
37 memcpy(&scope_size, buffer + *position, 4);
38 scope_size = BSON_UINT32_FROM_LE(scope_size);
39- if (scope_size < BSON_MIN_SIZE) {
40- Py_DECREF(code);
41- goto invalid;
42- }
43 /* code length + code + scope length + scope */
44- if ((4 + code_size + 4 + scope_size) != c_w_s_size) {
45+ len = 4 + 4 + code_size + scope_size;
46+ if (scope_size < BSON_MIN_SIZE || len != c_w_s_size || len < scope_size) {
47 Py_DECREF(code);
48 goto invalid;
49 }