diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-08-13 19:58:01 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-08-13 19:58:01 (GMT) |
commit | 2f8273898808caf92e38348c7fb3b00610a6315f (patch) | |
tree | 1d6408218f5efe1d489c64550f7a215d6dd25bce | |
parent | dffc1b8932d57c3a7d587b9571aac1c3a62e08f1 (diff) | |
download | cpython-2f8273898808caf92e38348c7fb3b00610a6315f.zip cpython-2f8273898808caf92e38348c7fb3b00610a6315f.tar.gz cpython-2f8273898808caf92e38348c7fb3b00610a6315f.tar.bz2 |
Backport of r77429. Not merged/blocked as svnmerge.py is not liking me right now.
-rw-r--r-- | Lib/test/test_pyexpat.py | 21 | ||||
-rw-r--r-- | Misc/ACKS | 3 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Modules/expat/xmltok_impl.c | 2 |
4 files changed, 25 insertions, 3 deletions
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 4947c8b..72795be 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -510,6 +510,24 @@ class ChardataBufferTest(unittest.TestCase): parser.Parse(xml2, 1) self.assertEquals(self.n, 4) +class MalformedInputText(unittest.TestCase): + def test1(self): + xml = "\0\r\n" + parser = expat.ParserCreate() + try: + parser.Parse(xml, True) + self.fail() + except expat.ExpatError as e: + self.assertEquals(str(e), 'no element found: line 2, column 1') + + def test2(self): + xml = "<?xml version\xc2\x85='1.0'?>\r\n" + parser = expat.ParserCreate() + try: + parser.Parse(xml, True) + self.fail() + except expat.ExpatError as e: + self.assertEquals(str(e), 'XML declaration not well-formed: line 1, column 14') def test_main(): run_unittest(SetAttributeTest, @@ -520,7 +538,8 @@ def test_main(): HandlerExceptionTest, PositionTest, sf1296433Test, - ChardataBufferTest) + ChardataBufferTest, + MalformedInputText) if __name__ == "__main__": test_main() @@ -184,6 +184,7 @@ Ismail Donmez Dima Dorfman Cesar Douady Dean Draayer +Fred L. Drake, Jr. John DuBois Paul Dubois Graham Dumpleton @@ -372,7 +373,6 @@ Irmen de Jong Lucas de Jonge John Jorgensen Jens B. Jorgensen -Fred L. Drake, Jr. Andreas Jung Tattoo Mabonzo K. Bob Kahn @@ -409,6 +409,7 @@ Holger Krekel Michael Kremer Fabian Kreutz Hannu Krosing +Ivan Krstić Andrew Kuchling Vladimir Kushnir Cameron Laird @@ -122,6 +122,8 @@ Library Extension Modules ----------------- +- Fix a segfault that could be triggered by expat with specially formed input. + - Issue #6561: '\d' in a regex now matches only characters with Unicode category 'Nd' (Number, Decimal Digit). Previously it also matched characters with category 'No'. diff --git a/Modules/expat/xmltok_impl.c b/Modules/expat/xmltok_impl.c index 0ee57ab..f793a6b 100644 --- a/Modules/expat/xmltok_impl.c +++ b/Modules/expat/xmltok_impl.c @@ -1741,7 +1741,7 @@ PREFIX(updatePosition)(const ENCODING *enc, const char *end, POSITION *pos) { - while (ptr != end) { + while (ptr < end) { switch (BYTE_TYPE(enc, ptr)) { #define LEAD_CASE(n) \ case BT_LEAD ## n: \ |