Prevent failures in the "scanning for endstream" code, in Parser_makeStream, by handling the case where 'endstream' is split between contiguous chunks (issue 1536)

This commit is contained in:
Jonas Jenwald 2016-01-25 22:56:34 +01:00
parent 051a0746e1
commit 15ce96a6eb
4 changed files with 32 additions and 13 deletions

View File

@ -488,23 +488,22 @@ var Parser = (function ParserClosure() {
break; break;
} }
found = false; found = false;
for (i = 0, j = 0; i < scanLength; i++) { i = 0;
var b = scanBytes[i]; while (i < scanLength) {
if (b !== ENDSTREAM_SIGNATURE[j]) { j = 0;
i -= j; while (j < ENDSTREAM_SIGNATURE_LENGTH &&
j = 0; scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
} else {
j++; j++;
if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
i++;
found = true;
break;
}
} }
if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
found = true;
break;
}
i++;
} }
if (found) { if (found) {
skipped += i - ENDSTREAM_SIGNATURE_LENGTH; skipped += i;
stream.pos += i - ENDSTREAM_SIGNATURE_LENGTH; stream.pos += i;
break; break;
} }
skipped += scanLength; skipped += scanLength;

View File

@ -0,0 +1 @@
http://web.archive.org/web/20150922201828/http://w2.eff.org/legal/cases/betamax/betamax_oral_argument2.pdf

View File

@ -0,0 +1 @@
http://web.archive.org/web/20160125220711/http://www.star.bnl.gov/public/daq/HARDWARE/21264_data_sheet.pdf

View File

@ -921,6 +921,24 @@
"rounds": 1, "rounds": 1,
"type": "eq" "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", { "id": "bpl13210",
"file": "pdfs/bpl13210.pdf", "file": "pdfs/bpl13210.pdf",
"md5": "8a08512baa9fa95378d9ad4b995947c7", "md5": "8a08512baa9fa95378d9ad4b995947c7",