Skip to content

Commit 3f8aa85

Browse files
committed
Bug 1829382 - use binary search in mozglue blocklist r=handyman
Someday I would like to figure out why this blocklist only works on ASCII strings and the freestanding one works on wide strings, but I'll leave that for another time I guess. This gets us closer to unifying the logic between the two blocklists, which is nice. I ran the TestDllBlocklist* gtests locally while using the mozglue blocklist and the ones that are expected to pass do indeed pass. Differential Revision: https://phabricator.services.mozilla.com/D176444 UltraBlame original commit: 169ca1394b2747cb91f95fe618faebef3fb1663e
1 parent c8f1d18 commit 3f8aa85

File tree

1 file changed

+107
-39
lines changed

1 file changed

+107
-39
lines changed

toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp

Lines changed: 107 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ ShouldBlockBasedOnBlockInfo
15851585
(
15861586
const
15871587
DllBlockInfo
1588-
*
1588+
&
15891589
info
15901590
const
15911591
char
@@ -1634,8 +1634,7 @@ endif
16341634
if
16351635
(
16361636
info
1637-
-
1638-
>
1637+
.
16391638
mFlags
16401639
&
16411640
DllBlockInfo
@@ -1665,8 +1664,7 @@ if
16651664
(
16661665
(
16671666
info
1668-
-
1669-
>
1667+
.
16701668
mFlags
16711669
&
16721670
DllBlockInfo
@@ -1689,8 +1687,7 @@ if
16891687
(
16901688
(
16911689
info
1692-
-
1693-
>
1690+
.
16941691
mFlags
16951692
&
16961693
DllBlockInfo
@@ -1713,8 +1710,7 @@ if
17131710
(
17141711
(
17151712
info
1716-
-
1717-
>
1713+
.
17181714
mFlags
17191715
&
17201716
DllBlockInfo
@@ -1740,8 +1736,7 @@ if
17401736
(
17411737
(
17421738
info
1743-
-
1744-
>
1739+
.
17451740
mFlags
17461741
&
17471742
DllBlockInfo
@@ -1767,8 +1762,7 @@ if
17671762
(
17681763
(
17691764
info
1770-
-
1771-
>
1765+
.
17721766
mFlags
17731767
&
17741768
DllBlockInfo
@@ -1794,8 +1788,7 @@ if
17941788
(
17951789
(
17961790
info
1797-
-
1798-
>
1791+
.
17991792
mFlags
18001793
&
18011794
DllBlockInfo
@@ -1821,8 +1814,7 @@ if
18211814
(
18221815
(
18231816
info
1824-
-
1825-
>
1817+
.
18261818
mFlags
18271819
&
18281820
DllBlockInfo
@@ -1854,8 +1846,7 @@ ALL_VERSIONS
18541846
if
18551847
(
18561848
info
1857-
-
1858-
>
1849+
.
18591850
mMaxVersion
18601851
!
18611852
=
@@ -1940,8 +1931,7 @@ true
19401931
if
19411932
(
19421933
info
1943-
-
1944-
>
1934+
.
19451935
mFlags
19461936
&
19471937
DllBlockInfo
@@ -1968,8 +1958,7 @@ if
19681958
fVersion
19691959
>
19701960
info
1971-
-
1972-
>
1961+
.
19731962
mMaxVersion
19741963
)
19751964
{
@@ -2006,8 +1995,7 @@ isOk
20061995
{
20071996
return
20081997
info
2009-
-
2010-
>
1998+
.
20111999
IsVersionBlocked
20122000
(
20132001
version
@@ -2024,6 +2012,53 @@ return
20242012
true
20252013
;
20262014
}
2015+
struct
2016+
CaseSensitiveStringComparator
2017+
{
2018+
explicit
2019+
CaseSensitiveStringComparator
2020+
(
2021+
const
2022+
char
2023+
*
2024+
aTarget
2025+
)
2026+
:
2027+
mTarget
2028+
(
2029+
aTarget
2030+
)
2031+
{
2032+
}
2033+
int
2034+
operator
2035+
(
2036+
)
2037+
(
2038+
const
2039+
DllBlockInfo
2040+
&
2041+
aVal
2042+
)
2043+
const
2044+
{
2045+
return
2046+
strcmp
2047+
(
2048+
mTarget
2049+
aVal
2050+
.
2051+
mName
2052+
)
2053+
;
2054+
}
2055+
const
2056+
char
2057+
*
2058+
mTarget
2059+
;
2060+
}
2061+
;
20272062
static
20282063
NTSTATUS
20292064
NTAPI
@@ -2456,28 +2491,56 @@ DECLARE_POINTER_TO_FIRST_DLL_BLOCKLIST_ENTRY
24562491
info
24572492
)
24582493
;
2459-
while
2494+
DECLARE_DLL_BLOCKLIST_NUM_ENTRIES
2495+
(
2496+
infoNumEntries
2497+
)
2498+
;
2499+
CaseSensitiveStringComparator
2500+
comp
2501+
(
2502+
dllName
2503+
)
2504+
;
2505+
size_t
2506+
match
2507+
=
2508+
LowerBound
24602509
(
24612510
info
2462-
-
2463-
>
2464-
mName
2511+
0
2512+
infoNumEntries
2513+
comp
24652514
)
2466-
{
2515+
;
24672516
if
24682517
(
2469-
strcmp
2518+
match
2519+
!
2520+
=
2521+
infoNumEntries
2522+
)
2523+
{
2524+
while
2525+
(
2526+
match
2527+
<
2528+
infoNumEntries
2529+
&
2530+
&
2531+
(
2532+
comp
24702533
(
24712534
info
2472-
-
2473-
>
2474-
mName
2475-
dllName
2535+
[
2536+
match
2537+
]
24762538
)
24772539
=
24782540
=
24792541
0
24802542
)
2543+
)
24812544
{
24822545
unsigned
24832546
long
@@ -2489,6 +2552,9 @@ if
24892552
ShouldBlockBasedOnBlockInfo
24902553
(
24912554
info
2555+
[
2556+
match
2557+
]
24922558
dllName
24932559
filePath
24942560
fname
@@ -2542,8 +2608,10 @@ DllBlockSet
25422608
Add
25432609
(
25442610
info
2545-
-
2546-
>
2611+
[
2612+
match
2613+
]
2614+
.
25472615
mName
25482616
fVersion
25492617
)
@@ -2552,13 +2620,13 @@ return
25522620
STATUS_DLL_NOT_FOUND
25532621
;
25542622
}
2555-
}
2556-
info
25572623
+
25582624
+
2625+
match
25592626
;
25602627
}
25612628
}
2629+
}
25622630
continue_loading
25632631
:
25642632
#

0 commit comments

Comments
 (0)