From 38855b1ff6bd67b96a531414b26a57477b70b8c3 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 22 Feb 2022 18:53:50 -0500 Subject: [PATCH] Fix testing a 8-bit integer instead of a 32-bit integer in PSL library Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2002 The code was testing only the LSB of a 32-bit integer to detect whether the current rule was a wildcard (`*`), while it had to compare against the whole 32-bit integer. The breakage occurred when the LSB of an offset to the character buffer happened to match the ASCII code of `*` (42, 0x2A). (An offset is used when a label is longer than 4 characters) --- src/lib/publicsuffixlist/publicsuffixlist.js | 2 +- .../publicsuffixlist/wasm/publicsuffixlist.wasm | Bin 408 -> 408 bytes .../publicsuffixlist/wasm/publicsuffixlist.wat | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/publicsuffixlist/publicsuffixlist.js b/src/lib/publicsuffixlist/publicsuffixlist.js index ccfdb6ab0..041d6ff0f 100644 --- a/src/lib/publicsuffixlist/publicsuffixlist.js +++ b/src/lib/publicsuffixlist/publicsuffixlist.js @@ -403,7 +403,7 @@ const getPublicSuffixPosJS = function() { } // 2. If no rules match, the prevailing rule is "*". if ( iFound === 0 ) { - if ( buf8[iCandidates + 1 << 2] !== 0x2A /* '*' */ ) { break; } + if ( buf8[iCandidates + 1] !== 0x2A /* '*' */ ) { break; } buf8[SUFFIX_NOT_FOUND_SLOT] = 1; iFound = iCandidates; } diff --git a/src/lib/publicsuffixlist/wasm/publicsuffixlist.wasm b/src/lib/publicsuffixlist/wasm/publicsuffixlist.wasm index 3e16e37ecb46e28307a508fefe5889df1b194f19..1f7ca0c35020afc6adb895d476ada03543f9d48d 100644 GIT binary patch delta 14 VcmbQiJcD_I3nP;T(_}ZsAOIbV1B3to delta 14 VcmbQiJcD_I3nP;*!(=zcAOIbp1BU