[Pkg-javascript-commits] [pdf.js] 154/414: Prevent failures in the "scanning for endstream" code, in `Parser_makeStream`, by handling the case where 'endstream' is split between contiguous chunks (issue 1536)

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:16 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 15ce96a6ebbe0bca93fac5a2527f7c6925aaba6f
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Mon Jan 25 22:56:34 2016 +0100

    Prevent failures in the "scanning for endstream" code, in `Parser_makeStream`, by handling the case where 'endstream' is split between contiguous chunks (issue 1536)
---
 src/core/parser.js           | 25 ++++++++++++-------------
 test/pdfs/issue1536.pdf.link |  1 +
 test/pdfs/issue2098.pdf.link |  1 +
 test/test_manifest.json      | 18 ++++++++++++++++++
 4 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/core/parser.js b/src/core/parser.js
index 71ec89e..a6cf10c 100644
--- a/src/core/parser.js
+++ b/src/core/parser.js
@@ -488,23 +488,22 @@ var Parser = (function ParserClosure() {
             break;
           }
           found = false;
-          for (i = 0, j = 0; i < scanLength; i++) {
-            var b = scanBytes[i];
-            if (b !== ENDSTREAM_SIGNATURE[j]) {
-              i -= j;
-              j = 0;
-            } else {
+          i = 0;
+          while (i < scanLength) {
+            j = 0;
+            while (j < ENDSTREAM_SIGNATURE_LENGTH &&
+                   scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
               j++;
-              if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
-                i++;
-                found = true;
-                break;
-              }
             }
+            if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
+              found = true;
+              break;
+            }
+            i++;
           }
           if (found) {
-            skipped += i - ENDSTREAM_SIGNATURE_LENGTH;
-            stream.pos += i - ENDSTREAM_SIGNATURE_LENGTH;
+            skipped += i;
+            stream.pos += i;
             break;
           }
           skipped += scanLength;
diff --git a/test/pdfs/issue1536.pdf.link b/test/pdfs/issue1536.pdf.link
new file mode 100644
index 0000000..c0af485
--- /dev/null
+++ b/test/pdfs/issue1536.pdf.link
@@ -0,0 +1 @@
+http://web.archive.org/web/20150922201828/http://w2.eff.org/legal/cases/betamax/betamax_oral_argument2.pdf
diff --git a/test/pdfs/issue2098.pdf.link b/test/pdfs/issue2098.pdf.link
new file mode 100644
index 0000000..c48db88
--- /dev/null
+++ b/test/pdfs/issue2098.pdf.link
@@ -0,0 +1 @@
+http://web.archive.org/web/20160125220711/http://www.star.bnl.gov/public/daq/HARDWARE/21264_data_sheet.pdf
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 7e664a5..249b018 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -921,6 +921,24 @@
        "rounds": 1,
        "type": "eq"
     },
+    {  "id": "issue1536",
+       "file": "pdfs/issue1536.pdf",
+       "md5": "bcaa52e6216399592ad5aa9fc49f1436",
+       "rounds": 1,
+       "link": true,
+       "firstPage": 6,
+       "lastPage": 6,
+       "type": "eq"
+    },
+    {  "id": "issue2098",
+       "file": "pdfs/issue2098.pdf",
+       "md5": "e9fa2b7cb935ffb95b510322d1e047e1",
+       "rounds": 1,
+       "link": true,
+       "firstPage": 1,
+       "lastPage": 1,
+       "type": "eq"
+    },
     {  "id": "bpl13210",
        "file": "pdfs/bpl13210.pdf",
        "md5": "8a08512baa9fa95378d9ad4b995947c7",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list