Blame SOURCES/freetype-2.10.4-properly-guard-face_index.patch

2a010a
From 22a0cccb4d9d002f33c1ba7a4b36812c7d4f46b5 Mon Sep 17 00:00:00 2001
2a010a
From: Werner Lemberg <wl@gnu.org>
2a010a
Date: Sat, 19 Mar 2022 06:40:17 +0100
2a010a
Subject: [PATCH] * src/base/ftobjs.c (ft_open_face_internal): Properly guard
2a010a
 `face_index`.
2a010a
2a010a
We must ensure that the cast to `FT_Int` doesn't change the sign.
2a010a
2a010a
Fixes #1139.
2a010a
---
2a010a
 src/base/ftobjs.c | 9 +++++++++
2a010a
 1 file changed, 9 insertions(+)
2a010a
2a010a
From d014387ad4a5dd04d8e7f99587c7dacb70261924 Mon Sep 17 00:00:00 2001
2a010a
From: Werner Lemberg <wl@gnu.org>
2a010a
Date: Sat, 19 Mar 2022 09:30:45 +0100
2a010a
Subject: [PATCH 2/2] * src/base/ftobjs.c (ft_open_face_internal): Thinko.
2a010a
2a010a
---
2a010a
 src/base/ftobjs.c | 1 +
2a010a
 1 file changed, 1 insertion(+)
2a010a
2a010a
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
2a010a
index 2c0f0e6c9..10952a6c6 100644
2a010a
--- a/src/base/ftobjs.c
2a010a
+++ b/src/base/ftobjs.c
2a010a
@@ -2527,6 +2527,16 @@
2a010a
 #endif
2a010a
 
2a010a
 
2a010a
+    /* only use lower 31 bits together with sign bit */
2a010a
+    if ( face_index > 0 )
2a010a
+      face_index &= 0x7FFFFFFFL;
2a010a
+    else
2a010a
+    {
2a010a
+      face_index  = -face_index;
2a010a
+      face_index &= 0x7FFFFFFFL;
2a010a
+      face_index  = -face_index;
2a010a
+    }
2a010a
+
2a010a
 #ifdef FT_DEBUG_LEVEL_TRACE
2a010a
     FT_TRACE3(( "FT_Open_Face: " ));
2a010a
     if ( face_index < 0 )
2a010a
-- 
2a010a
2.35.1
2a010a