summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryanjun.zhu <yanjun.zhu@windriver.com>2013-03-04 12:35:57 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-04 09:58:17 +0000
commit96d0ef130d43c59f449cb3e744b9f9ba71bdacd3 (patch)
treeac75c6b6a04ea6cdb5931a24cae2204a9c7bdf9e
parent82cb88e6157cc264ba714cc5d2de7f5933f1408e (diff)
downloadpoky-96d0ef130d43c59f449cb3e744b9f9ba71bdacd3.tar.gz
Python: Fix for CVE-2012-2135
Reference:http://bugs.python.org/issue14579 The utf-16 decoder in Python 3.1 through 3.3 does not update the aligned_end variable after calling the unicode_decode_call_errorhandler function, which allows remote attackers to obtain sensitive information (process memory) or cause a denial of service (memory corruption and crash) via unspecified vectors. http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-2135 [YOCTO #3450] (From OE-Core rev: f60d3efe93323b7056a9400a483e625a3fed4491) Signed-off-by: yanjun.zhu <yanjun.zhu@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/python/python/python-2.7.3-CVE-2012-2135.patch73
-rw-r--r--meta/recipes-devtools/python/python_2.7.3.bb3
2 files changed, 75 insertions, 1 deletions
diff --git a/meta/recipes-devtools/python/python/python-2.7.3-CVE-2012-2135.patch b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2012-2135.patch
new file mode 100644
index 0000000000..3afdbc0f6e
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2012-2135.patch
@@ -0,0 +1,73 @@
1Upstream-Status: Backport
2
3Reference:http://bugs.python.org/issue14579
4
5The utf-16 decoder in Python 3.1 through 3.3 does not update the
6aligned_end variable after calling the unicode_decode_call_errorhandler
7function, which allows remote attackers to obtain sensitive information
8(process memory) or cause a denial of service (memory corruption and crash)
9via unspecified vectors.
10
11http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-2135
12
13diff -urpN a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
14--- a/Lib/test/test_codecs.py
15+++ b/Lib/test/test_codecs.py
16@@ -495,8 +495,21 @@ class UTF16LETest(ReadTest):
17 )
18
19 def test_errors(self):
20- self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode, "\xff", "strict", True)
21-
22+ tests = [
23+ (b'\xff', u'\ufffd'),
24+ (b'A\x00Z', u'A\ufffd'),
25+ (b'A\x00B\x00C\x00D\x00Z', u'ABCD\ufffd'),
26+ (b'\x00\xd8', u'\ufffd'),
27+ (b'\x00\xd8A', u'\ufffd'),
28+ (b'\x00\xd8A\x00', u'\ufffdA'),
29+ (b'\x00\xdcA\x00', u'\ufffdA'),
30+ ]
31+ for raw, expected in tests:
32+ print('*****', raw, expected)
33+ self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode,
34+ raw, 'strict', True)
35+ self.assertEqual(raw.decode('utf-16le', 'replace'), expected)
36+
37 class UTF16BETest(ReadTest):
38 encoding = "utf-16-be"
39
40@@ -516,7 +529,20 @@ class UTF16BETest(ReadTest):
41 )
42
43 def test_errors(self):
44- self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode, "\xff", "strict", True)
45+ tests = [
46+ (b'\xff', u'\ufffd'),
47+ (b'\x00A\xff', u'A\ufffd'),
48+ (b'\x00A\x00B\x00C\x00DZ', u'ABCD\ufffd'),
49+ (b'\xd8\x00', u'\ufffd'),
50+ (b'\xd8\x00\xdc', u'\ufffd'),
51+ (b'\xd8\x00\x00A', u'\ufffdA'),
52+ (b'\xdc\x00\x00A', u'\ufffdA'),
53+ ]
54+ for raw, expected in tests:
55+ print('*****', raw, expected)
56+ self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode,
57+ raw, 'strict', True)
58+ self.assertEqual(raw.decode('utf-16be', 'replace'), expected)
59
60 class UTF8Test(ReadTest):
61 encoding = "utf-8"
62diff -urpN a/Objects/unicodeobject.c b/Objects/unicodeobject.c
63--- a/Objects/unicodeobject.c 2013-03-04 11:34:34.000000000 +0800
64+++ b/Objects/unicodeobject.c 2013-03-04 11:36:01.000000000 +0800
65@@ -2564,7 +2564,7 @@ PyUnicode_DecodeUTF16Stateful(const char
66 }
67
68 /* UTF-16 code pair: */
69- if (q >= e) {
70+ if (e - q < 2) {
71 errmsg = "unexpected end of data";
72 startinpos = (((const char *)q)-2)-starts;
73 endinpos = ((const char *)e)-starts;
diff --git a/meta/recipes-devtools/python/python_2.7.3.bb b/meta/recipes-devtools/python/python_2.7.3.bb
index f0d5c90d30..c181933a64 100644
--- a/meta/recipes-devtools/python/python_2.7.3.bb
+++ b/meta/recipes-devtools/python/python_2.7.3.bb
@@ -1,6 +1,6 @@
1require python.inc 1require python.inc
2DEPENDS = "python-native bzip2 db gdbm openssl readline sqlite3 zlib" 2DEPENDS = "python-native bzip2 db gdbm openssl readline sqlite3 zlib"
3PR = "${INC_PR}.2" 3PR = "${INC_PR}.3"
4 4
5DISTRO_SRC_URI ?= "file://sitecustomize.py" 5DISTRO_SRC_URI ?= "file://sitecustomize.py"
6DISTRO_SRC_URI_linuxstdbase = "" 6DISTRO_SRC_URI_linuxstdbase = ""
@@ -28,6 +28,7 @@ SRC_URI += "\
28 file://python-2.7.3-berkeley-db-5.3.patch \ 28 file://python-2.7.3-berkeley-db-5.3.patch \
29 file://python-2.7.3-remove-bsdb-rpath.patch \ 29 file://python-2.7.3-remove-bsdb-rpath.patch \
30 file://builddir.patch \ 30 file://builddir.patch \
31 file://python-2.7.3-CVE-2012-2135.patch \
31" 32"
32 33
33S = "${WORKDIR}/Python-${PV}" 34S = "${WORKDIR}/Python-${PV}"