|
|
@@ -349,11 +349,13 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
|
|
|
|
|
|
function compareBytes(mask, pattern) {
|
|
|
let patternMatch = true, index = 0;
|
|
|
- const value = new Uint8Array(buffer, 0, mask.length);
|
|
|
- for (index = 0; index < mask.length && patternMatch; index++) {
|
|
|
- patternMatch = patternMatch && ((value[index] & mask[index]) == pattern[index]);
|
|
|
+ if (buffer.byteLength >= pattern.length) {
|
|
|
+ const value = new Uint8Array(buffer, 0, mask.length);
|
|
|
+ for (index = 0; index < mask.length && patternMatch; index++) {
|
|
|
+ patternMatch = patternMatch && ((value[index] & mask[index]) == pattern[index]);
|
|
|
+ }
|
|
|
+ return patternMatch;
|
|
|
}
|
|
|
- return patternMatch && (index == mask.length);
|
|
|
}
|
|
|
}
|
|
|
|