Skip to content

Commit 135f0e5

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 779cc2f commit 135f0e5

File tree

1 file changed

+143
-38
lines changed

1 file changed

+143
-38
lines changed

toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp

Lines changed: 143 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ ShouldBlockBasedOnBlockInfo
22632263
(
22642264
const
22652265
DllBlockInfo
2266-
*
2266+
&
22672267
info
22682268
const
22692269
char
@@ -2312,8 +2312,7 @@ endif
23122312
if
23132313
(
23142314
info
2315-
-
2316-
>
2315+
.
23172316
mFlags
23182317
&
23192318
DllBlockInfo
@@ -2343,8 +2342,7 @@ if
23432342
(
23442343
(
23452344
info
2346-
-
2347-
>
2345+
.
23482346
mFlags
23492347
&
23502348
DllBlockInfo
@@ -2367,8 +2365,7 @@ if
23672365
(
23682366
(
23692367
info
2370-
-
2371-
>
2368+
.
23722369
mFlags
23732370
&
23742371
DllBlockInfo
@@ -2391,8 +2388,7 @@ if
23912388
(
23922389
(
23932390
info
2394-
-
2395-
>
2391+
.
23962392
mFlags
23972393
&
23982394
DllBlockInfo
@@ -2418,8 +2414,7 @@ if
24182414
(
24192415
(
24202416
info
2421-
-
2422-
>
2417+
.
24232418
mFlags
24242419
&
24252420
DllBlockInfo
@@ -2445,8 +2440,7 @@ if
24452440
(
24462441
(
24472442
info
2448-
-
2449-
>
2443+
.
24502444
mFlags
24512445
&
24522446
DllBlockInfo
@@ -2472,8 +2466,7 @@ if
24722466
(
24732467
(
24742468
info
2475-
-
2476-
>
2469+
.
24772470
mFlags
24782471
&
24792472
DllBlockInfo
@@ -2499,8 +2492,7 @@ if
24992492
(
25002493
(
25012494
info
2502-
-
2503-
>
2495+
.
25042496
mFlags
25052497
&
25062498
DllBlockInfo
@@ -2532,8 +2524,7 @@ ALL_VERSIONS
25322524
if
25332525
(
25342526
info
2535-
-
2536-
>
2527+
.
25372528
mMaxVersion
25382529
!
25392530
=
@@ -2634,8 +2625,7 @@ true
26342625
if
26352626
(
26362627
info
2637-
-
2638-
>
2628+
.
26392629
mFlags
26402630
&
26412631
DllBlockInfo
@@ -2662,8 +2652,7 @@ if
26622652
fVersion
26632653
>
26642654
info
2665-
-
2666-
>
2655+
.
26672656
mMaxVersion
26682657
)
26692658
{
@@ -2713,8 +2702,7 @@ isOk
27132702
{
27142703
return
27152704
info
2716-
-
2717-
>
2705+
.
27182706
IsVersionBlocked
27192707
(
27202708
version
@@ -2742,6 +2730,53 @@ return
27422730
true
27432731
;
27442732
}
2733+
struct
2734+
CaseSensitiveStringComparator
2735+
{
2736+
explicit
2737+
CaseSensitiveStringComparator
2738+
(
2739+
const
2740+
char
2741+
*
2742+
aTarget
2743+
)
2744+
:
2745+
mTarget
2746+
(
2747+
aTarget
2748+
)
2749+
{
2750+
}
2751+
int
2752+
operator
2753+
(
2754+
)
2755+
(
2756+
const
2757+
DllBlockInfo
2758+
&
2759+
aVal
2760+
)
2761+
const
2762+
{
2763+
return
2764+
strcmp
2765+
(
2766+
mTarget
2767+
aVal
2768+
.
2769+
mName
2770+
)
2771+
;
2772+
}
2773+
const
2774+
char
2775+
*
2776+
mTarget
2777+
;
2778+
}
2779+
;
27452780
static
27462781
NTSTATUS
27472782
NTAPI
@@ -3406,28 +3441,93 @@ DECLARE_POINTER_TO_FIRST_DLL_BLOCKLIST_ENTRY
34063441
info
34073442
)
34083443
;
3409-
while
3444+
DECLARE_DLL_BLOCKLIST_NUM_ENTRIES
3445+
(
3446+
infoNumEntries
3447+
)
3448+
;
3449+
CaseSensitiveStringComparator
3450+
comp
3451+
(
3452+
dllName
3453+
)
3454+
;
3455+
size_t
3456+
match
3457+
=
3458+
LowerBound
34103459
(
34113460
info
3412-
-
3413-
>
3414-
mName
3461+
0
3462+
infoNumEntries
3463+
comp
3464+
)
3465+
;
3466+
if
3467+
(
3468+
match
3469+
!
3470+
=
3471+
infoNumEntries
34153472
)
34163473
{
3474+
/
3475+
/
3476+
There
3477+
may
3478+
be
3479+
multiple
3480+
entries
3481+
on
3482+
the
3483+
list
3484+
.
3485+
Since
3486+
LowerBound
3487+
(
3488+
)
3489+
returns
3490+
/
3491+
/
3492+
the
3493+
first
3494+
entry
3495+
that
3496+
matches
3497+
(
34173498
if
3499+
there
3500+
are
3501+
any
3502+
matches
3503+
)
3504+
/
3505+
/
3506+
search
3507+
forward
3508+
from
3509+
there
3510+
.
3511+
while
34183512
(
3419-
strcmp
3513+
match
3514+
<
3515+
infoNumEntries
3516+
&
3517+
&
3518+
(
3519+
comp
34203520
(
34213521
info
3422-
-
3423-
>
3424-
mName
3425-
dllName
3522+
[
3523+
match
3524+
]
34263525
)
34273526
=
34283527
=
34293528
0
34303529
)
3530+
)
34313531
{
34323532
unsigned
34333533
long
@@ -3439,6 +3539,9 @@ if
34393539
ShouldBlockBasedOnBlockInfo
34403540
(
34413541
info
3542+
[
3543+
match
3544+
]
34423545
dllName
34433546
filePath
34443547
fname
@@ -3492,8 +3595,10 @@ DllBlockSet
34923595
Add
34933596
(
34943597
info
3495-
-
3496-
>
3598+
[
3599+
match
3600+
]
3601+
.
34973602
mName
34983603
fVersion
34993604
)
@@ -3502,13 +3607,13 @@ return
35023607
STATUS_DLL_NOT_FOUND
35033608
;
35043609
}
3505-
}
3506-
info
35073610
+
35083611
+
3612+
match
35093613
;
35103614
}
35113615
}
3616+
}
35123617
continue_loading
35133618
:
35143619
#

0 commit comments

Comments
 (0)