diff options
author | Paul Ivanov <pivanov5@bloomberg.net> | 2019-01-30 14:22:44 -0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2019-04-16 22:49:18 -0600 |
commit | a4df7e51483c78853bb33814073498fb027aa9d4 (patch) | |
tree | a9cdc264030b97da13eeb533224a206d5bf65643 /numpy/lib/format.py | |
parent | cc94f360febdef0e6c4183c50555ba82e60ccff6 (diff) | |
download | numpy-a4df7e51483c78853bb33814073498fb027aa9d4.tar.gz |
BUG: load fails when using pickle without allow_pickle=True
a partial mitigation of #12759.
see also https://nvd.nist.gov/vuln/detail/CVE-2019-6446
Diffstat (limited to 'numpy/lib/format.py')
-rw-r--r-- | numpy/lib/format.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 4da1022ca..553c9371d 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -149,7 +149,7 @@ data HEADER_LEN." Notes ----- The ``.npy`` format, including motivation for creating it and a comparison of -alternatives, is described in the `"npy-format" NEP +alternatives, is described in the `"npy-format" NEP <https://www.numpy.org/neps/nep-0001-npy-format.html>`_, however details have evolved with time and this document is more current. @@ -644,7 +644,7 @@ def write_array(fp, array, version=None, allow_pickle=True, pickle_kwargs=None): fp.write(chunk.tobytes('C')) -def read_array(fp, allow_pickle=True, pickle_kwargs=None): +def read_array(fp, allow_pickle=False, pickle_kwargs=None): """ Read an array from an NPY file. @@ -654,7 +654,11 @@ def read_array(fp, allow_pickle=True, pickle_kwargs=None): If this is not a real file object, then this may take extra memory and time. allow_pickle : bool, optional - Whether to allow reading pickled data. Default: True + Whether to allow writing pickled data. Default: False + + .. versionchanged:: 1.16.3 + Made default False in response to CVE-2019-6446. + pickle_kwargs : dict Additional keyword arguments to pass to pickle.load. These are only useful when loading object arrays saved on Python 2 when using |