summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python-numpy/files/CVE-2021-41496.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/python-numpy/files/CVE-2021-41496.patch')
-rw-r--r--meta/recipes-devtools/python-numpy/files/CVE-2021-41496.patch64
1 files changed, 64 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python-numpy/files/CVE-2021-41496.patch b/meta/recipes-devtools/python-numpy/files/CVE-2021-41496.patch
new file mode 100644
index 0000000000..0afc79ae0d
--- /dev/null
+++ b/meta/recipes-devtools/python-numpy/files/CVE-2021-41496.patch
@@ -0,0 +1,64 @@
1From 86d81322c5c0ab67f89d64f56f6e77d4fe185910 Mon Sep 17 00:00:00 2001
2From: Warren Weckesser <warren.weckesser@gmail.com>
3Date: Tue, 29 Mar 2022 15:58:00 +0800
4Subject: [PATCH] BUG: f2py: Simplify creation of an exception message. Closes
5 gh-19000.
6
7CVE: CVE-2021-41496
8
9Upstream-Status: Backport [https://github.com/numpy/numpy/commit/271010f1037150e95017f803f4214b8861e528f2]
10
11Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
12---
13 numpy/f2py/src/fortranobject.c | 26 ++++++++++++--------------
14 1 file changed, 12 insertions(+), 14 deletions(-)
15
16diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c
17index 3275f90..85c9c7f 100644
18--- a/numpy/f2py/src/fortranobject.c
19+++ b/numpy/f2py/src/fortranobject.c
20@@ -637,14 +637,14 @@ static int check_and_fix_dimensions(const PyArrayObject* arr,
21 npy_intp *dims);
22
23 static int
24-count_negative_dimensions(const int rank,
25+find_first_negative_dimension(const int rank,
26 const npy_intp *dims) {
27- int i=0,r=0;
28- while (i<rank) {
29- if (dims[i] < 0) ++r;
30- ++i;
31+ for (int i = 0; i < rank; ++i) {
32+ if (dims[i] < 0) {
33+ return i;
34+ }
35 }
36- return r;
37+ return -1;
38 }
39
40 #ifdef DEBUG_COPY_ND_ARRAY
41@@ -721,14 +721,12 @@ PyArrayObject* array_from_pyobj(const int type_num,
42 || ((intent & F2PY_OPTIONAL) && (obj==Py_None))
43 ) {
44 /* intent(cache), optional, intent(hide) */
45- if (count_negative_dimensions(rank,dims) > 0) {
46- int i;
47- strcpy(mess, "failed to create intent(cache|hide)|optional array"
48- "-- must have defined dimensions but got (");
49- for(i=0;i<rank;++i)
50- sprintf(mess+strlen(mess),"%" NPY_INTP_FMT ",",dims[i]);
51- strcat(mess, ")");
52- PyErr_SetString(PyExc_ValueError,mess);
53+ int i = find_first_negative_dimension(rank, dims);
54+ if (i >= 0) {
55+ PyErr_Format(PyExc_ValueError,
56+ "failed to create intent(cache|hide)|optional array"
57+ " -- must have defined dimensions, but dims[%d] = %"
58+ NPY_INTP_FMT, i, dims[i]);
59 return NULL;
60 }
61 arr = (PyArrayObject *)
62--
632.25.1
64