[Jython-checkins] jython: Ensure that bz2 decompression has enough data to decode.

jim.baker jython-checkins at python.org
Sun Jun 22 07:59:45 CEST 2014


http://hg.python.org/jython/rev/02a31eb57af2
changeset:   7309:02a31eb57af2
user:        Indra Talip <indra.talip at gmail.com>
date:        Sat Jun 21 23:05:02 2014 -0600
summary:
  Ensure that bz2 decompression has enough data to decode.

Fixes http://bugs.jython.org/issue2040
Merged from https://bitbucket.org/jython/jython/pull-request/24/the-pybz2decompressor-should-check-that/

files:
  src/org/python/modules/bz2/PyBZ2Decompressor.java |  3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)


diff --git a/src/org/python/modules/bz2/PyBZ2Decompressor.java b/src/org/python/modules/bz2/PyBZ2Decompressor.java
--- a/src/org/python/modules/bz2/PyBZ2Decompressor.java
+++ b/src/org/python/modules/bz2/PyBZ2Decompressor.java
@@ -69,7 +69,8 @@
         ByteArrayOutputStream decodedStream = new ByteArrayOutputStream();
         final byte[] buf = accumulator;
         for (int i = 0; i < buf.length; i++) {
-            if (((char) buf[i] == '\\') && ((char) buf[i + 1] == 'x')) {
+            if (((i + 3) < buf.length) &&
+                (((char) buf[i] == '\\') && ((char) buf[i + 1] == 'x'))) {
                 int decodedByte = ((Character.digit((char) buf[i + 2], 16) << 4) + Character
                         .digit((char) buf[i + 3], 16));
                 decodedStream.write(decodedByte);

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list