From 73ee9c346f3acccbe14a4caf258b636de7c459be Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 7 Jul 2023 22:47:20 -0600 Subject: [PATCH] Revert "[sanitize] Only check trailing edge of ranges" This reverts commit e4856cf8098b9741a910e7f7979096cf11d8fead. This is wrong on at least 32-bit systems. Might add a condition version later. --- src/hb-sanitize.hh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hb-sanitize.hh b/src/hb-sanitize.hh index 566364319..d10ebdf74 100644 --- a/src/hb-sanitize.hh +++ b/src/hb-sanitize.hh @@ -268,7 +268,8 @@ struct hb_sanitize_context_t : unsigned int len) const { const char *p = (const char *) base; - bool ok = (intptr_t) (this->end - p) >= (intptr_t) len && + bool ok = (uintptr_t) (p - this->start) <= this->length && + (unsigned int) (this->end - p) >= len && ((this->max_ops -= len) > 0); DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, @@ -287,7 +288,8 @@ struct hb_sanitize_context_t : unsigned int len) const { const char *p = (const char *) base; - bool ok = (intptr_t) (this->end - p) >= (intptr_t) len; + bool ok = ((uintptr_t) (p - this->start) <= this->length && + (unsigned int) (this->end - p) >= len); DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, "check_range_fast [%p..%p]"