Debian Codegraph @

debian/patches/CVE-2026-10009

raw
1 From 7c9ffcb347d4169fdca223d21cc62c2c0420db66 Mon Sep 17 00:00:00 2001
2 From: Kaylee Lubick <[email protected]>
3 Date: Tue, 19 May 2026 15:07:23 +0000
4 Subject: [PATCH] Avoid overflow and timeout in SkPathWriter::assemble
5
6 I was unable to make a test case that caused an overflow
7 and didn't timeout, but I think the possibility exists
8 for both.
9
10 This removes that, adds a few defensive asserts, and
11 makes one assert actually checked at runtime, just to be safe.
12
13 Change-Id: I4ce112624cb346ac7597466ac9c78402c5061e1c
14 Bug: https://issues.chromium.org/issues/513973560
15 Fixed: 513973560
16 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1239556
17 Reviewed-by: Thomas Smith <[email protected]>
18 ---
19 src/pathops/SkPathWriter.cpp | 19 +++++++++++++++++--
20 1 file changed, 17 insertions(+), 2 deletions(-)
21
22 --- a/src/pathops/SkPathWriter.cpp
23 +++ b/src/pathops/SkPathWriter.cpp
24 @@ -55,6 +55,7 @@
25 }
26
27 bool SkPathWriter::deferredLine(const SkOpPtT* pt) {
28 + SkASSERT(pt);
29 SkASSERT(fFirstPtT);
30 SkASSERT(fDefer[0]);
31 if (fDefer[0] == pt) {
32 @@ -77,6 +78,7 @@
33 }
34
35 void SkPathWriter::deferredMove(const SkOpPtT* pt) {
36 + SkASSERT(pt);
37 if (!fDefer[1]) {
38 fFirstPtT = fDefer[0] = pt;
39 return;
40 @@ -160,6 +162,7 @@
41 // if last point to be written matches the current path's first point, alter the
42 // last to avoid writing a degenerate lineTo when the path is closed
43 SkPoint SkPathWriter::update(const SkOpPtT* pt) {
44 + SkASSERT(pt);
45 if (!fDefer[1]) {
46 this->moveTo();
47 } else if (!this->matchedLast(fDefer[0])) {
48 @@ -179,6 +182,7 @@
49 }
50
51 bool SkPathWriter::changedSlopes(const SkOpPtT* ptT) const {
52 + SkASSERT(ptT);
53 if (matchedLast(fDefer[0])) {
54 return false;
55 }
56 @@ -213,7 +217,15 @@
57 SkOpPtT const* const* runs = fEndPtTs.begin(); // starts, ends of partial contours
58 int endCount = fEndPtTs.size(); // all starts and ends
59 SkASSERT(endCount > 0);
60 - SkASSERT(endCount == fPartials.size() * 2);
61 + SkASSERT(endCount == (int)fPartials.size() * 2);
62 +
63 + // Limit the number of partial contours to avoid O(N^2) complexity and integer overflows.
64 + // 10,000 partial contours results in 20,000 ends and ~200,000,000 distance entries.
65 + constexpr int kMaxPartialContours = 10000;
66 + if (endCount > kMaxPartialContours * 2) {
67 + return;
68 + }
69 +
70 #if DEBUG_ASSEMBLE
71 for (int index = 0; index < endCount; index += 2) {
72 const SkOpPtT* eStart = runs[index];
73 @@ -363,7 +375,10 @@
74 if (forward) {
75 next = contourPts.empty() ? SkPoint{0, 0} : contourPts.front();
76 } else {
77 - SkASSERT(!contourPts.empty());
78 + if (contourPts.empty()) {
79 + SkDEBUGFAIL("unexpected empty contour");
80 + return;
81 + }
82 next = contourPts.back();
83 }
84 if (*prior != next) {