Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6763a71

Browse files
brianosmanSkia Commit-Bot
authored andcommitted
Limit morphology radius to 100 pixels
This limit is arbitrary, but hopefully prevents pathological (or malicious) SVG content from consuming huge amounts of CPU/GPU time, without impacting any legitimate uses of feMorphology. (Typical usage has a much smaller radius). Bug: chromium:1123035 Change-Id: I4405bc595128e9a6287eb5efa1be14621baa3a00 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/315219 Reviewed-by: Mike Reed <[email protected]> Commit-Queue: Brian Osman <[email protected]>
1 parent 1ee21cd commit 6763a71

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/effects/imagefilters/SkMorphologyImageFilter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,9 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilterImpl::onFilterImage(const Context&
637637
int height = SkScalarRoundToInt(radius.height());
638638

639639
// Width (or height) must fit in a signed 32-bit int to avoid UBSAN issues (crbug.com/1018190)
640-
constexpr int kMaxRadius = (std::numeric_limits<int>::max() - 1) / 2;
640+
// Further, we limit the radius to something much smaller, to avoid extremely slow draw calls:
641+
// (crbug.com/1123035):
642+
constexpr int kMaxRadius = 100; // (std::numeric_limits<int>::max() - 1) / 2;
641643

642644
if (width < 0 || height < 0 || width > kMaxRadius || height > kMaxRadius) {
643645
return nullptr;

0 commit comments

Comments
 (0)