Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
python-numpy.26461
CVE-2021-41496-bufovrflw-fortranobject-DoS.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File CVE-2021-41496-bufovrflw-fortranobject-DoS.patch of Package python-numpy.26461
From 271010f1037150e95017f803f4214b8861e528f2 Mon Sep 17 00:00:00 2001 From: Warren Weckesser <warren.weckesser@gmail.com> Date: Mon, 20 Dec 2021 10:35:31 -0500 Subject: [PATCH] BUG: f2py: Simplify creation of an exception message. Closes gh-19000. --- numpy/f2py/src/fortranobject.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -589,6 +589,17 @@ static int swap_arrays(PyArrayObject* ar ||(PyArray_ISBOOL(arr) && PyTypeNum_ISBOOL(type_num)) \ ) +static int +find_first_negative_dimension(const int rank, const npy_intp *dims) +{ + for (int i = 0; i < rank; ++i) { + if (dims[i] < 0) { + return i; + } + } + return -1; +} + extern PyArrayObject* array_from_pyobj(const int type_num, npy_intp *dims, @@ -617,14 +628,12 @@ PyArrayObject* array_from_pyobj(const in || ((intent & F2PY_OPTIONAL) && (obj==Py_None)) ) { /* intent(cache), optional, intent(hide) */ - if (count_nonpos(rank,dims)) { - int i; - sprintf(mess,"failed to create intent(cache|hide)|optional array" - "-- must have defined dimensions but got ("); - for(i=0;i<rank;++i) - sprintf(mess+strlen(mess),"%" NPY_INTP_FMT ",",dims[i]); - sprintf(mess+strlen(mess),")"); - PyErr_SetString(PyExc_ValueError,mess); + int i = find_first_negative_dimension(rank, dims); + if (i >= 0) { + PyErr_Format(PyExc_ValueError, + "failed to create intent(cache|hide)|optional array" + " -- must have defined dimensions, but dims[%d] = %" + NPY_INTP_FMT, i, dims[i]); return NULL; } arr = (PyArrayObject *)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor