harfbuzz/backport-CVE-2023-25193.patch

32 lines
1.0 KiB
Diff
Raw Normal View History

2023-02-15 06:23:31 +00:00
From 85be877925ddbf34f74a1229f3ca1716bb6170dc Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod <behdad@behdad.org>
Date: Wed, 1 Feb 2023 20:00:43 -0700
Subject: [PATCH] [layout] Limit how far we skip when looking back
See comments.
---
2023-02-22 17:41:48 +08:00
src/hb-ot-layout-gsubgpos.hh | 7 +++++++
1 file changed, 7 insertions(+)
2023-02-15 06:23:31 +00:00
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
2023-02-22 17:41:48 +08:00
index bf74672a1..8ca691805 100644
2023-02-15 06:23:31 +00:00
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
2023-02-22 17:41:48 +08:00
@@ -578,6 +578,13 @@ struct hb_ot_apply_context_t :
unsigned stop = num_items - 1;
if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT)
stop = 1 - 1;
2023-02-15 06:23:31 +00:00
+
+ /* When looking back, limit how far we search; this function is mostly
+ * used for looking back for base glyphs when attaching marks. If we
+ * don't limit, we can get O(n^2) behavior where n is the number of
+ * consecutive marks. */
+ stop = (unsigned) hb_max ((int) stop, (int) idx - HB_MAX_CONTEXT_LENGTH);
+
2023-02-22 17:41:48 +08:00
while (idx > stop)
2023-02-15 06:23:31 +00:00
{
idx--;
--
2023-02-22 17:41:48 +08:00
2.20.1
2023-02-15 06:23:31 +00:00