mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Ensure that MurmurHash3_64.update
handles ArrayBuffer
input correctly, to avoid hash-collisions (issue 12533)
Different fonts incorrectly end up with *identical* hashes, despite having different /ToUnicode data. The issue, and it's very interesting that we've apparently not seen it before, appears to be caused by the fact that different /ToUnicode entries share the *same* underlying `ArrayBuffer`, which thus becomes problematic at the `const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);` line. The simplest solution thus seem to be to just *copy* the input, when it's an `ArrayBuffer`, rather than using it as-is. (Note that if we'd stringified the input, when calling `MurmurHash3_64.update`, the issue would also have been fixed. In this case, we're already creating an unique TypedArray.)
This commit is contained in:
parent
b2a4dacd31
commit
f2fa053c51
3 changed files with 11 additions and 1 deletions
|
@ -45,7 +45,7 @@ class MurmurHash3_64 {
|
|||
}
|
||||
}
|
||||
} else if (isArrayBuffer(input)) {
|
||||
data = input;
|
||||
data = input.slice();
|
||||
length = data.byteLength;
|
||||
} else {
|
||||
throw new Error(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue