From c69ec6f5bb42f9efe56e9c8086624458a359c5ae Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 29 Jun 2022 16:32:30 -0600 Subject: [PATCH] [kern2] Fix sanitize issue on 32bit systems Fixes https://github.com/harfbuzz/harfbuzz/issues/3483 --- src/hb-aat-layout-common.hh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 1db0f1df9..8809008b8 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -681,6 +681,13 @@ struct ObsoleteTypes const void *base, const T *array) { + /* https://github.com/harfbuzz/harfbuzz/issues/3483 */ + /* If offset is less than base, return an offset that would + * result in an address half a 32bit address-space away, + * to make sure sanitize fails even on 32bit builds. */ + if (offset < unsigned ((const char *) array - (const char *) base)) + return INT_MAX / T::static_size; + /* https://github.com/harfbuzz/harfbuzz/issues/2816 */ return (offset - unsigned ((const char *) array - (const char *) base)) / T::static_size; }