Update python2 to version 2.7.15 to address CVE-2018-1060 and CVE-2018-1061.
Change-Id: Ie53efcb2944d920d418eb51bde7f832b6f7c6aaf
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5502
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Sharath George
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,13 +0,0 @@ |
| 1 |
-#Forcing ncurses module to compile with stack-protector flag |
|
| 2 |
-+++ b/setup.py 2016-06-20 18:20:23.721857009 -0700 |
|
| 3 |
-@@ -1354,7 +1354,8 @@ |
|
| 4 |
- [os.path.join(d, 'ncursesw') for d in inc_dirs]) |
|
| 5 |
- exts.append( Extension('_curses', ['_cursesmodule.c'],
|
|
| 6 |
- include_dirs = curses_incs, |
|
| 7 |
-- libraries = curses_libs) ) |
|
| 8 |
-+ libraries = curses_libs, |
|
| 9 |
-+ extra_compile_args=['-fstack-protector']) ) |
|
| 10 |
- elif curses_library == 'curses' and host_platform != 'darwin': |
|
| 11 |
- # OSX has an old Berkeley curses, not good enough for |
|
| 12 |
- # the _curses module. |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 |
-+++ b/Lib/ssl.py 2017-03-22 17:24:55.165374501 -0700 |
|
| 2 |
-@@ -146,6 +146,11 @@ |
|
| 1 |
+--- a/Lib/ssl.py 2018-04-30 04:17:33.000000000 +0530 |
|
| 2 |
+@@ -146,6 +146,11 @@ from socket import SOL_SOCKET, SO_TYPE |
|
| 3 | 3 |
import base64 # for DER-to-PEM translation |
| 4 | 4 |
import errno |
| 5 | 5 |
import warnings |
| ... | ... |
@@ -12,7 +12,7 @@ |
| 12 | 12 |
|
| 13 | 13 |
if _ssl.HAS_TLS_UNIQUE: |
| 14 | 14 |
CHANNEL_BINDING_TYPES = ['tls-unique'] |
| 15 |
-@@ -245,7 +250,15 @@ |
|
| 15 |
+@@ -251,7 +250,15 @@ def _dnsname_match(dn, hostname, max_wil |
|
| 16 | 16 |
pat = re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE) |
| 17 | 17 |
return pat.match(hostname) |
| 18 | 18 |
|
| ... | ... |
@@ -28,7 +28,7 @@ |
| 28 | 28 |
def match_hostname(cert, hostname): |
| 29 | 29 |
"""Verify that *cert* (in decoded format as returned by |
| 30 | 30 |
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 |
| 31 |
-@@ -258,6 +271,13 @@ |
|
| 31 |
+@@ -264,6 +271,13 @@ def match_hostname(cert, hostname): |
|
| 32 | 32 |
raise ValueError("empty or no certificate, match_hostname needs a "
|
| 33 | 33 |
"SSL socket or SSL context with either " |
| 34 | 34 |
"CERT_OPTIONAL or CERT_REQUIRED") |
| ... | ... |
@@ -42,7 +42,7 @@ |
| 42 | 42 |
dnsnames = [] |
| 43 | 43 |
san = cert.get('subjectAltName', ())
|
| 44 | 44 |
for key, value in san: |
| 45 |
-@@ -265,6 +285,10 @@ |
|
| 45 |
+@@ -271,6 +285,10 @@ def match_hostname(cert, hostname): |
|
| 46 | 46 |
if _dnsname_match(value, hostname): |
| 47 | 47 |
return |
| 48 | 48 |
dnsnames.append(value) |
| 49 | 49 |
deleted file mode 100644 |
| ... | ... |
@@ -1,23 +0,0 @@ |
| 1 |
-# HG changeset patch |
|
| 2 |
-# User Benjamin Peterson <benjamin@python.org> |
|
| 3 |
-# Date 1453357424 28800 |
|
| 4 |
-# Node ID 985fc64c60d6adffd1138b6cc46df388ca91ca5d |
|
| 5 |
-# Parent 7ec954b9fc54448a35b56d271340ba109eb381b9 |
|
| 6 |
-prevent buffer overflow in get_data (closes #26171) |
|
| 7 |
- |
|
| 8 |
-diff --git a/Modules/zipimport.c b/Modules/zipimport.c |
|
| 9 |
-+++ b/Modules/zipimport.c |
|
| 10 |
-@@ -895,6 +895,11 @@ get_data(char *archive, PyObject *toc_en |
|
| 11 |
- PyMarshal_ReadShortFromFile(fp); /* local header size */ |
|
| 12 |
- file_offset += l; /* Start of file data */ |
|
| 13 |
- |
|
| 14 |
-+ if (data_size > LONG_MAX - 1) {
|
|
| 15 |
-+ fclose(fp); |
|
| 16 |
-+ PyErr_NoMemory(); |
|
| 17 |
-+ return NULL; |
|
| 18 |
-+ } |
|
| 19 |
- raw_data = PyString_FromStringAndSize((char *)NULL, compress == 0 ? |
|
| 20 |
- data_size : data_size + 1); |
|
| 21 |
- if (raw_data == NULL) {
|
|
| 22 |
- |
| 23 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,41 +0,0 @@ |
| 1 |
-From c3c9db89273fabc62ea1b48389d9a3000c1c03ae Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Jay Bosamiya <jaybosamiya@gmail.com> |
|
| 3 |
-Date: Sun, 18 Jun 2017 22:11:03 +0530 |
|
| 4 |
-Subject: [PATCH] [2.7] bpo-30657: Check & prevent integer overflow in |
|
| 5 |
- PyString_DecodeEscape (#2174) |
|
| 6 |
- |
|
| 7 |
- Misc/ACKS | 1 + |
|
| 8 |
- Misc/NEWS | 3 +++ |
|
| 9 |
- Objects/stringobject.c | 8 +++++++- |
|
| 10 |
- 3 files changed, 11 insertions(+), 1 deletion(-) |
|
| 11 |
- |
|
| 12 |
-diff --git a/Misc/ACKS b/Misc/ACKS |
|
| 13 |
-index 95be42717a0..a411bc5ffc8 100644 |
|
| 14 |
-+++ b/Misc/ACKS |
|
| 15 |
-@@ -152,6 +152,7 @@ Gregory Bond |
|
| 16 |
- Matias Bordese |
|
| 17 |
- Jonas Borgström |
|
| 18 |
- Jurjen Bos |
|
| 19 |
-+Jay Bosamiya |
|
| 20 |
- Peter Bosch |
|
| 21 |
- Dan Boswell |
|
| 22 |
- Eric Bouck |
|
| 23 |
-+++ b/Objects/stringobject.c |
|
| 24 |
-@@ -612,7 +612,13 @@ PyObject *PyString_DecodeEscape(const char *s, |
|
| 25 |
- char *p, *buf; |
|
| 26 |
- const char *end; |
|
| 27 |
- PyObject *v; |
|
| 28 |
-- Py_ssize_t newlen = recode_encoding ? 4*len:len; |
|
| 29 |
-+ Py_ssize_t newlen; |
|
| 30 |
-+ /* Check for integer overflow */ |
|
| 31 |
-+ if (recode_encoding && (len > PY_SSIZE_T_MAX / 4)) {
|
|
| 32 |
-+ PyErr_SetString(PyExc_OverflowError, "string is too large"); |
|
| 33 |
-+ return NULL; |
|
| 34 |
-+ } |
|
| 35 |
-+ newlen = recode_encoding ? 4*len:len; |
|
| 36 |
- v = PyString_FromStringAndSize((char *)NULL, newlen); |
|
| 37 |
- if (v == NULL) |
|
| 38 |
- return NULL; |
| 39 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,113 +0,0 @@ |
| 1 |
-From 6401e5671781eb217ee1afb4603cc0d1b0367ae6 Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Serhiy Storchaka <storchaka@gmail.com> |
|
| 3 |
-Date: Fri, 10 Nov 2017 12:58:55 +0200 |
|
| 4 |
-Subject: [PATCH] [2.7] bpo-31530: Stop crashes when iterating over a file on |
|
| 5 |
- multiple threads. (#3672) |
|
| 6 |
- |
|
| 7 |
- Lib/test/test_file2k.py | 32 ++++++++++++++++++++++ |
|
| 8 |
- .../2017-09-20-18-28-09.bpo-31530.CdLOM7.rst | 4 +++ |
|
| 9 |
- Objects/fileobject.c | 19 +++++++++++-- |
|
| 10 |
- 3 files changed, 52 insertions(+), 3 deletions(-) |
|
| 11 |
- create mode 100644 Misc/NEWS.d/next/Core and Builtins/2017-09-20-18-28-09.bpo-31530.CdLOM7.rst |
|
| 12 |
- |
|
| 13 |
-diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py |
|
| 14 |
-index e39ef7042eae..d8966e034e08 100644 |
|
| 15 |
-+++ b/Lib/test/test_file2k.py |
|
| 16 |
-@@ -652,6 +652,38 @@ def io_func(): |
|
| 17 |
- self.f.writelines('')
|
|
| 18 |
- self._test_close_open_io(io_func) |
|
| 19 |
- |
|
| 20 |
-+ def test_iteration_torture(self): |
|
| 21 |
-+ # bpo-31530: Crash when concurrently iterate over a file. |
|
| 22 |
-+ with open(self.filename, "wb") as fp: |
|
| 23 |
-+ for i in xrange(2**20): |
|
| 24 |
-+ fp.write(b"0"*50 + b"\n") |
|
| 25 |
-+ with open(self.filename, "rb") as f: |
|
| 26 |
-+ def iterate(): |
|
| 27 |
-+ try: |
|
| 28 |
-+ for l in f: |
|
| 29 |
-+ pass |
|
| 30 |
-+ except IOError: |
|
| 31 |
-+ pass |
|
| 32 |
-+ self._run_workers(iterate, 10) |
|
| 33 |
-+ |
|
| 34 |
-+ def test_iteration_seek(self): |
|
| 35 |
-+ # bpo-31530: Crash when concurrently seek and iterate over a file. |
|
| 36 |
-+ with open(self.filename, "wb") as fp: |
|
| 37 |
-+ for i in xrange(10000): |
|
| 38 |
-+ fp.write(b"0"*50 + b"\n") |
|
| 39 |
-+ with open(self.filename, "rb") as f: |
|
| 40 |
-+ it = iter([1] + [0]*10) # one thread reads, others seek |
|
| 41 |
-+ def iterate(): |
|
| 42 |
-+ try: |
|
| 43 |
-+ if next(it): |
|
| 44 |
-+ for l in f: |
|
| 45 |
-+ pass |
|
| 46 |
-+ else: |
|
| 47 |
-+ for i in range(100): |
|
| 48 |
-+ f.seek(i*100, 0) |
|
| 49 |
-+ except IOError: |
|
| 50 |
-+ pass |
|
| 51 |
-+ self._run_workers(iterate, 10) |
|
| 52 |
- |
|
| 53 |
- @unittest.skipUnless(os.name == 'posix', 'test requires a posix system.') |
|
| 54 |
- class TestFileSignalEINTR(unittest.TestCase): |
|
| 55 |
-diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-09-20-18-28-09.bpo-31530.CdLOM7.rst b/Misc/NEWS.d/next/Core and Builtins/2017-09-20-18-28-09.bpo-31530.CdLOM7.rst |
|
| 56 |
-new file mode 100644 |
|
| 57 |
-index 000000000000..a6cb6c9e9ba9 |
|
| 58 |
-+++ b/Misc/NEWS.d/next/Core and Builtins/2017-09-20-18-28-09.bpo-31530.CdLOM7.rst |
|
| 59 |
-@@ -0,0 +1,4 @@ |
|
| 60 |
-+Fixed crashes when iterating over a file on multiple threads. |
|
| 61 |
-+seek() and next() methods of file objects now raise an exception during |
|
| 62 |
-+concurrent operation on the same file object. |
|
| 63 |
-+A lock can be used to prevent the error. |
|
| 64 |
-diff --git a/Objects/fileobject.c b/Objects/fileobject.c |
|
| 65 |
-index 7e07a5376f88..2f63c374d1e2 100644 |
|
| 66 |
-+++ b/Objects/fileobject.c |
|
| 67 |
-@@ -762,6 +762,12 @@ file_seek(PyFileObject *f, PyObject *args) |
|
| 68 |
- |
|
| 69 |
- if (f->f_fp == NULL) |
|
| 70 |
- return err_closed(); |
|
| 71 |
-+ if (f->unlocked_count > 0) {
|
|
| 72 |
-+ PyErr_SetString(PyExc_IOError, |
|
| 73 |
-+ "seek() called during concurrent " |
|
| 74 |
-+ "operation on the same file object"); |
|
| 75 |
-+ return NULL; |
|
| 76 |
-+ } |
|
| 77 |
- drop_readahead(f); |
|
| 78 |
- whence = 0; |
|
| 79 |
- if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &whence)) |
|
| 80 |
-@@ -2238,6 +2244,7 @@ readahead(PyFileObject *f, Py_ssize_t bufsize) |
|
| 81 |
- {
|
|
| 82 |
- Py_ssize_t chunksize; |
|
| 83 |
- |
|
| 84 |
-+ assert(f->unlocked_count == 0); |
|
| 85 |
- if (f->f_buf != NULL) {
|
|
| 86 |
- if( (f->f_bufend - f->f_bufptr) >= 1) |
|
| 87 |
- return 0; |
|
| 88 |
-@@ -2279,6 +2286,12 @@ readahead_get_line_skip(PyFileObject *f, Py_ssize_t skip, Py_ssize_t bufsize) |
|
| 89 |
- char *buf; |
|
| 90 |
- Py_ssize_t len; |
|
| 91 |
- |
|
| 92 |
-+ if (f->unlocked_count > 0) {
|
|
| 93 |
-+ PyErr_SetString(PyExc_IOError, |
|
| 94 |
-+ "next() called during concurrent " |
|
| 95 |
-+ "operation on the same file object"); |
|
| 96 |
-+ return NULL; |
|
| 97 |
-+ } |
|
| 98 |
- if (f->f_buf == NULL) |
|
| 99 |
- if (readahead(f, bufsize) < 0) |
|
| 100 |
- return NULL; |
|
| 101 |
-@@ -2692,7 +2705,7 @@ int PyObject_AsFileDescriptor(PyObject *o) |
|
| 102 |
- } |
|
| 103 |
- else {
|
|
| 104 |
- PyErr_SetString(PyExc_TypeError, |
|
| 105 |
-- "argument must be an int, or have a fileno() method."); |
|
| 106 |
-+ "argument must be an int, or have a fileno() method"); |
|
| 107 |
- return -1; |
|
| 108 |
- } |
|
| 109 |
- |
| 110 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,297 +0,0 @@ |
| 1 |
-From dbf52e02f18dac6f5f0a64f78932f3dc6efc056b Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Benjamin Peterson <benjamin@python.org> |
|
| 3 |
-Date: Tue, 2 Jan 2018 09:25:41 -0800 |
|
| 4 |
-Subject: [PATCH] bpo-31530: fix crash when multiple threads iterate over a |
|
| 5 |
- file, round 2 (#5060) |
|
| 6 |
- |
|
| 7 |
-Multiple threads iterating over a file can corrupt the file's internal readahead |
|
| 8 |
-buffer resulting in crashes. To fix this, cache buffer state thread-locally for |
|
| 9 |
-the duration of a file_iternext call and only update the file's internal state |
|
| 10 |
-after reading completes. |
|
| 11 |
- |
|
| 12 |
-No attempt is made to define or provide "reasonable" semantics for iterating |
|
| 13 |
-over a file on multiple threads. (Non-crashing) races are still |
|
| 14 |
-present. Duplicated, corrupt, and missing data will happen. |
|
| 15 |
- |
|
| 16 |
-This was originally fixed by 6401e5671781eb217ee1afb4603cc0d1b0367ae6, which |
|
| 17 |
-raised an exception from seek() and next() when concurrent operations were |
|
| 18 |
-detected. Alas, this simpler solution breaks legitimate use cases such as |
|
| 19 |
-capturing the standard streams when multiple threads are logging. |
|
| 20 |
- Lib/test/test_file2k.py | 27 ++--- |
|
| 21 |
- .../2017-09-20-18-28-09.bpo-31530.CdLOM7.rst | 3 - |
|
| 22 |
- Objects/fileobject.c | 118 ++++++++++++--------- |
|
| 23 |
- 3 files changed, 78 insertions(+), 70 deletions(-) |
|
| 24 |
- |
|
| 25 |
-diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py |
|
| 26 |
-index d8966e034e08..c73e8d8dc450 100644 |
|
| 27 |
-+++ b/Lib/test/test_file2k.py |
|
| 28 |
-@@ -653,18 +653,15 @@ def io_func(): |
|
| 29 |
- self._test_close_open_io(io_func) |
|
| 30 |
- |
|
| 31 |
- def test_iteration_torture(self): |
|
| 32 |
-- # bpo-31530: Crash when concurrently iterate over a file. |
|
| 33 |
-+ # bpo-31530 |
|
| 34 |
- with open(self.filename, "wb") as fp: |
|
| 35 |
- for i in xrange(2**20): |
|
| 36 |
- fp.write(b"0"*50 + b"\n") |
|
| 37 |
- with open(self.filename, "rb") as f: |
|
| 38 |
-- def iterate(): |
|
| 39 |
-- try: |
|
| 40 |
-- for l in f: |
|
| 41 |
-- pass |
|
| 42 |
-- except IOError: |
|
| 43 |
-+ def it(): |
|
| 44 |
-+ for l in f: |
|
| 45 |
- pass |
|
| 46 |
-- self._run_workers(iterate, 10) |
|
| 47 |
-+ self._run_workers(it, 10) |
|
| 48 |
- |
|
| 49 |
- def test_iteration_seek(self): |
|
| 50 |
- # bpo-31530: Crash when concurrently seek and iterate over a file. |
|
| 51 |
-@@ -674,17 +671,15 @@ def test_iteration_seek(self): |
|
| 52 |
- with open(self.filename, "rb") as f: |
|
| 53 |
- it = iter([1] + [0]*10) # one thread reads, others seek |
|
| 54 |
- def iterate(): |
|
| 55 |
-- try: |
|
| 56 |
-- if next(it): |
|
| 57 |
-- for l in f: |
|
| 58 |
-- pass |
|
| 59 |
-- else: |
|
| 60 |
-- for i in range(100): |
|
| 61 |
-- f.seek(i*100, 0) |
|
| 62 |
-- except IOError: |
|
| 63 |
-- pass |
|
| 64 |
-+ if next(it): |
|
| 65 |
-+ for l in f: |
|
| 66 |
-+ pass |
|
| 67 |
-+ else: |
|
| 68 |
-+ for i in xrange(100): |
|
| 69 |
-+ f.seek(i*100, 0) |
|
| 70 |
- self._run_workers(iterate, 10) |
|
| 71 |
- |
|
| 72 |
-+ |
|
| 73 |
- @unittest.skipUnless(os.name == 'posix', 'test requires a posix system.') |
|
| 74 |
- class TestFileSignalEINTR(unittest.TestCase): |
|
| 75 |
- def _test_reading(self, data_to_write, read_and_verify_code, method_name, |
|
| 76 |
-diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-09-20-18-28-09.bpo-31530.CdLOM7.rst b/Misc/NEWS.d/next/Core and Builtins/2017-09-20-18-28-09.bpo-31530.CdLOM7.rst |
|
| 77 |
-index a6cb6c9e9ba9..beb09b5ae650 100644 |
|
| 78 |
-+++ b/Misc/NEWS.d/next/Core and Builtins/2017-09-20-18-28-09.bpo-31530.CdLOM7.rst |
|
| 79 |
-@@ -1,4 +1 @@ |
|
| 80 |
- Fixed crashes when iterating over a file on multiple threads. |
|
| 81 |
--seek() and next() methods of file objects now raise an exception during |
|
| 82 |
--concurrent operation on the same file object. |
|
| 83 |
--A lock can be used to prevent the error. |
|
| 84 |
-diff --git a/Objects/fileobject.c b/Objects/fileobject.c |
|
| 85 |
-index 8d1c5812f0d2..270b28264a8f 100644 |
|
| 86 |
-+++ b/Objects/fileobject.c |
|
| 87 |
-@@ -609,7 +609,12 @@ err_iterbuffered(void) |
|
| 88 |
- return NULL; |
|
| 89 |
- } |
|
| 90 |
- |
|
| 91 |
--static void drop_readahead(PyFileObject *); |
|
| 92 |
-+static void |
|
| 93 |
-+drop_file_readahead(PyFileObject *f) |
|
| 94 |
-+{
|
|
| 95 |
-+ PyMem_FREE(f->f_buf); |
|
| 96 |
-+ f->f_buf = NULL; |
|
| 97 |
-+} |
|
| 98 |
- |
|
| 99 |
- /* Methods */ |
|
| 100 |
- |
|
| 101 |
-@@ -632,7 +637,7 @@ file_dealloc(PyFileObject *f) |
|
| 102 |
- Py_XDECREF(f->f_mode); |
|
| 103 |
- Py_XDECREF(f->f_encoding); |
|
| 104 |
- Py_XDECREF(f->f_errors); |
|
| 105 |
-- drop_readahead(f); |
|
| 106 |
-+ drop_file_readahead(f); |
|
| 107 |
- Py_TYPE(f)->tp_free((PyObject *)f); |
|
| 108 |
- } |
|
| 109 |
- |
|
| 110 |
-@@ -767,13 +772,7 @@ file_seek(PyFileObject *f, PyObject *args) |
|
| 111 |
- |
|
| 112 |
- if (f->f_fp == NULL) |
|
| 113 |
- return err_closed(); |
|
| 114 |
-- if (f->unlocked_count > 0) {
|
|
| 115 |
-- PyErr_SetString(PyExc_IOError, |
|
| 116 |
-- "seek() called during concurrent " |
|
| 117 |
-- "operation on the same file object"); |
|
| 118 |
-- return NULL; |
|
| 119 |
-- } |
|
| 120 |
-- drop_readahead(f); |
|
| 121 |
-+ drop_file_readahead(f); |
|
| 122 |
- whence = 0; |
|
| 123 |
- if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &whence)) |
|
| 124 |
- return NULL; |
|
| 125 |
-@@ -2242,12 +2241,16 @@ static PyGetSetDef file_getsetlist[] = {
|
|
| 126 |
- {0},
|
|
| 127 |
- }; |
|
| 128 |
- |
|
| 129 |
-+typedef struct {
|
|
| 130 |
-+ char *buf, *bufptr, *bufend; |
|
| 131 |
-+} readaheadbuffer; |
|
| 132 |
-+ |
|
| 133 |
- static void |
|
| 134 |
--drop_readahead(PyFileObject *f) |
|
| 135 |
-+drop_readaheadbuffer(readaheadbuffer *rab) |
|
| 136 |
- {
|
|
| 137 |
-- if (f->f_buf != NULL) {
|
|
| 138 |
-- PyMem_Free(f->f_buf); |
|
| 139 |
-- f->f_buf = NULL; |
|
| 140 |
-+ if (rab->buf != NULL) {
|
|
| 141 |
-+ PyMem_FREE(rab->buf); |
|
| 142 |
-+ rab->buf = NULL; |
|
| 143 |
- } |
|
| 144 |
- } |
|
| 145 |
- |
|
| 146 |
-@@ -2255,36 +2258,34 @@ drop_readahead(PyFileObject *f) |
|
| 147 |
- (unless at EOF) and no more than bufsize. Returns negative value on |
|
| 148 |
- error, will set MemoryError if bufsize bytes cannot be allocated. */ |
|
| 149 |
- static int |
|
| 150 |
--readahead(PyFileObject *f, Py_ssize_t bufsize) |
|
| 151 |
-+readahead(PyFileObject *f, readaheadbuffer *rab, Py_ssize_t bufsize) |
|
| 152 |
- {
|
|
| 153 |
- Py_ssize_t chunksize; |
|
| 154 |
- |
|
| 155 |
-- assert(f->unlocked_count == 0); |
|
| 156 |
-- if (f->f_buf != NULL) {
|
|
| 157 |
-- if( (f->f_bufend - f->f_bufptr) >= 1) |
|
| 158 |
-+ if (rab->buf != NULL) {
|
|
| 159 |
-+ if ((rab->bufend - rab->bufptr) >= 1) |
|
| 160 |
- return 0; |
|
| 161 |
- else |
|
| 162 |
-- drop_readahead(f); |
|
| 163 |
-+ drop_readaheadbuffer(rab); |
|
| 164 |
- } |
|
| 165 |
-- if ((f->f_buf = (char *)PyMem_Malloc(bufsize)) == NULL) {
|
|
| 166 |
-+ if ((rab->buf = PyMem_MALLOC(bufsize)) == NULL) {
|
|
| 167 |
- PyErr_NoMemory(); |
|
| 168 |
- return -1; |
|
| 169 |
- } |
|
| 170 |
- FILE_BEGIN_ALLOW_THREADS(f) |
|
| 171 |
- errno = 0; |
|
| 172 |
-- chunksize = Py_UniversalNewlineFread( |
|
| 173 |
-- f->f_buf, bufsize, f->f_fp, (PyObject *)f); |
|
| 174 |
-+ chunksize = Py_UniversalNewlineFread(rab->buf, bufsize, f->f_fp, (PyObject *)f); |
|
| 175 |
- FILE_END_ALLOW_THREADS(f) |
|
| 176 |
- if (chunksize == 0) {
|
|
| 177 |
- if (ferror(f->f_fp)) {
|
|
| 178 |
- PyErr_SetFromErrno(PyExc_IOError); |
|
| 179 |
- clearerr(f->f_fp); |
|
| 180 |
-- drop_readahead(f); |
|
| 181 |
-+ drop_readaheadbuffer(rab); |
|
| 182 |
- return -1; |
|
| 183 |
- } |
|
| 184 |
- } |
|
| 185 |
-- f->f_bufptr = f->f_buf; |
|
| 186 |
-- f->f_bufend = f->f_buf + chunksize; |
|
| 187 |
-+ rab->bufptr = rab->buf; |
|
| 188 |
-+ rab->bufend = rab->buf + chunksize; |
|
| 189 |
- return 0; |
|
| 190 |
- } |
|
| 191 |
- |
|
| 192 |
-@@ -2294,51 +2295,43 @@ readahead(PyFileObject *f, Py_ssize_t bufsize) |
|
| 193 |
- logarithmic buffer growth to about 50 even when reading a 1gb line. */ |
|
| 194 |
- |
|
| 195 |
- static PyStringObject * |
|
| 196 |
--readahead_get_line_skip(PyFileObject *f, Py_ssize_t skip, Py_ssize_t bufsize) |
|
| 197 |
-+readahead_get_line_skip(PyFileObject *f, readaheadbuffer *rab, Py_ssize_t skip, Py_ssize_t bufsize) |
|
| 198 |
- {
|
|
| 199 |
- PyStringObject* s; |
|
| 200 |
- char *bufptr; |
|
| 201 |
- char *buf; |
|
| 202 |
- Py_ssize_t len; |
|
| 203 |
- |
|
| 204 |
-- if (f->unlocked_count > 0) {
|
|
| 205 |
-- PyErr_SetString(PyExc_IOError, |
|
| 206 |
-- "next() called during concurrent " |
|
| 207 |
-- "operation on the same file object"); |
|
| 208 |
-- return NULL; |
|
| 209 |
-- } |
|
| 210 |
-- if (f->f_buf == NULL) |
|
| 211 |
-- if (readahead(f, bufsize) < 0) |
|
| 212 |
-+ if (rab->buf == NULL) |
|
| 213 |
-+ if (readahead(f, rab, bufsize) < 0) |
|
| 214 |
- return NULL; |
|
| 215 |
- |
|
| 216 |
-- len = f->f_bufend - f->f_bufptr; |
|
| 217 |
-+ len = rab->bufend - rab->bufptr; |
|
| 218 |
- if (len == 0) |
|
| 219 |
-- return (PyStringObject *) |
|
| 220 |
-- PyString_FromStringAndSize(NULL, skip); |
|
| 221 |
-- bufptr = (char *)memchr(f->f_bufptr, '\n', len); |
|
| 222 |
-+ return (PyStringObject *)PyString_FromStringAndSize(NULL, skip); |
|
| 223 |
-+ bufptr = (char *)memchr(rab->bufptr, '\n', len); |
|
| 224 |
- if (bufptr != NULL) {
|
|
| 225 |
- bufptr++; /* Count the '\n' */ |
|
| 226 |
-- len = bufptr - f->f_bufptr; |
|
| 227 |
-- s = (PyStringObject *) |
|
| 228 |
-- PyString_FromStringAndSize(NULL, skip + len); |
|
| 229 |
-+ len = bufptr - rab->bufptr; |
|
| 230 |
-+ s = (PyStringObject *)PyString_FromStringAndSize(NULL, skip + len); |
|
| 231 |
- if (s == NULL) |
|
| 232 |
- return NULL; |
|
| 233 |
-- memcpy(PyString_AS_STRING(s) + skip, f->f_bufptr, len); |
|
| 234 |
-- f->f_bufptr = bufptr; |
|
| 235 |
-- if (bufptr == f->f_bufend) |
|
| 236 |
-- drop_readahead(f); |
|
| 237 |
-+ memcpy(PyString_AS_STRING(s) + skip, rab->bufptr, len); |
|
| 238 |
-+ rab->bufptr = bufptr; |
|
| 239 |
-+ if (bufptr == rab->bufend) |
|
| 240 |
-+ drop_readaheadbuffer(rab); |
|
| 241 |
- } else {
|
|
| 242 |
-- bufptr = f->f_bufptr; |
|
| 243 |
-- buf = f->f_buf; |
|
| 244 |
-- f->f_buf = NULL; /* Force new readahead buffer */ |
|
| 245 |
-+ bufptr = rab->bufptr; |
|
| 246 |
-+ buf = rab->buf; |
|
| 247 |
-+ rab->buf = NULL; /* Force new readahead buffer */ |
|
| 248 |
- assert(len <= PY_SSIZE_T_MAX - skip); |
|
| 249 |
-- s = readahead_get_line_skip(f, skip + len, bufsize + (bufsize>>2)); |
|
| 250 |
-+ s = readahead_get_line_skip(f, rab, skip + len, bufsize + (bufsize>>2)); |
|
| 251 |
- if (s == NULL) {
|
|
| 252 |
-- PyMem_Free(buf); |
|
| 253 |
-+ PyMem_FREE(buf); |
|
| 254 |
- return NULL; |
|
| 255 |
- } |
|
| 256 |
- memcpy(PyString_AS_STRING(s) + skip, bufptr, len); |
|
| 257 |
-- PyMem_Free(buf); |
|
| 258 |
-+ PyMem_FREE(buf); |
|
| 259 |
- } |
|
| 260 |
- return s; |
|
| 261 |
- } |
|
| 262 |
-@@ -2356,7 +2349,30 @@ file_iternext(PyFileObject *f) |
|
| 263 |
- if (!f->readable) |
|
| 264 |
- return err_mode("reading");
|
|
| 265 |
- |
|
| 266 |
-- l = readahead_get_line_skip(f, 0, READAHEAD_BUFSIZE); |
|
| 267 |
-+ {
|
|
| 268 |
-+ /* |
|
| 269 |
-+ Multiple threads can enter this method while the GIL is released |
|
| 270 |
-+ during file read and wreak havoc on the file object's readahead |
|
| 271 |
-+ buffer. To avoid dealing with cross-thread coordination issues, we |
|
| 272 |
-+ cache the file buffer state locally and only set it back on the file |
|
| 273 |
-+ object when we're done. |
|
| 274 |
-+ */ |
|
| 275 |
-+ readaheadbuffer rab = {f->f_buf, f->f_bufptr, f->f_bufend};
|
|
| 276 |
-+ f->f_buf = NULL; |
|
| 277 |
-+ l = readahead_get_line_skip(f, &rab, 0, READAHEAD_BUFSIZE); |
|
| 278 |
-+ /* |
|
| 279 |
-+ Make sure the file's internal read buffer is cleared out. This will |
|
| 280 |
-+ only do anything if some other thread interleaved with us during |
|
| 281 |
-+ readahead. We want to drop any changeling buffer, so we don't leak |
|
| 282 |
-+ memory. We may lose data, but that's what you get for reading the same |
|
| 283 |
-+ file object in multiple threads. |
|
| 284 |
-+ */ |
|
| 285 |
-+ drop_file_readahead(f); |
|
| 286 |
-+ f->f_buf = rab.buf; |
|
| 287 |
-+ f->f_bufptr = rab.bufptr; |
|
| 288 |
-+ f->f_bufend = rab.bufend; |
|
| 289 |
-+ } |
|
| 290 |
-+ |
|
| 291 |
- if (l == NULL || PyString_GET_SIZE(l) == 0) {
|
|
| 292 |
- Py_XDECREF(l); |
|
| 293 |
- return NULL; |
| ... | ... |
@@ -1,20 +1,16 @@ |
| 1 | 1 |
Summary: A high-level scripting language |
| 2 | 2 |
Name: python2 |
| 3 |
-Version: 2.7.13 |
|
| 4 |
-Release: 5%{?dist}
|
|
| 3 |
+Version: 2.7.15 |
|
| 4 |
+Release: 1%{?dist}
|
|
| 5 | 5 |
License: PSF |
| 6 | 6 |
URL: http://www.python.org/ |
| 7 | 7 |
Group: System Environment/Programming |
| 8 | 8 |
Vendor: VMware, Inc. |
| 9 | 9 |
Distribution: Photon |
| 10 | 10 |
Source0: http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.xz
|
| 11 |
-%define sha1 Python=18a8f30a0356c751b8d0ea6f76e764cab13ee046 |
|
| 11 |
+%define sha1 Python=f99348a095ec4a6411c84c0d15343d11920c9724 |
|
| 12 | 12 |
Patch0: cgi.patch |
| 13 |
-Patch1: added-compiler-flags-for-curses-module.patch |
|
| 14 |
-Patch2: added-pyopenssl-ipaddress-certificate-validation.patch |
|
| 15 |
-Patch3: python2-CVE-2017-1000158.patch |
|
| 16 |
-Patch4: python2-CVE-2018-1000030-1.patch |
|
| 17 |
-Patch5: python2-CVE-2018-1000030-2.patch |
|
| 13 |
+Patch1: added-pyopenssl-ipaddress-certificate-validation.patch |
|
| 18 | 14 |
BuildRequires: pkg-config >= 0.28 |
| 19 | 15 |
BuildRequires: bzip2-devel |
| 20 | 16 |
BuildRequires: openssl-devel |
| ... | ... |
@@ -104,10 +100,6 @@ to build python programs. |
| 104 | 104 |
%setup -q -n Python-%{version}
|
| 105 | 105 |
%patch0 -p1 |
| 106 | 106 |
%patch1 -p1 |
| 107 |
-%patch2 -p1 |
|
| 108 |
-%patch3 -p1 |
|
| 109 |
-%patch4 -p1 |
|
| 110 |
-%patch5 -p1 |
|
| 111 | 107 |
|
| 112 | 108 |
%build |
| 113 | 109 |
export OPT="${CFLAGS}"
|
| ... | ... |
@@ -225,6 +217,8 @@ rm -rf %{buildroot}/*
|
| 225 | 225 |
%{_bindir}/idle*
|
| 226 | 226 |
|
| 227 | 227 |
%changelog |
| 228 |
+* Fri Aug 17 2018 Dweep Advani <dadvani@vmware.com> 2.7.15-1 |
|
| 229 |
+- Update to version 2.7.15 |
|
| 228 | 230 |
* Mon Dec 04 2017 Xiaolin Li <xiaolinl@vmware.com> 2.7.13-5 |
| 229 | 231 |
- Fix CVE-2017-1000030 |
| 230 | 232 |
* Mon Dec 04 2017 Xiaolin Li <xiaolinl@vmware.com> 2.7.13-4 |