[sanitize] Enlighten check_range() some more

No need to check for len=0 arrays. They must still be in range.
This commit is contained in:
Behdad Esfahbod committed 2023-07-07 21:02:15 -06:00
1 parent c24ea1036b
commit 6a683ea6eb
2 files changed
+5 -5

No files matched your search

+2 -1
View File
@@ -258,7 +258,8 @@ struct fvar
axisSize == 20 && /* Assumed in our code. */
instanceSize >= axisCount * 4 + 4 &&
get_axes ().sanitize (c) &&
c->check_range (get_instance (0), instanceCount, instanceSize));
c->check_range (&StructAfter<InstanceRecord> (get_axes ()),
instanceCount, instanceSize));
}
unsigned int get_axis_count () const { return axisCount; }
+3 -4
View File
@@ -268,10 +268,9 @@ struct hb_sanitize_context_t :
unsigned int len) const
{
const char *p = (const char *) base;
bool ok = !len ||
((uintptr_t) (p - this->start) <= this->length &&
(unsigned int) (this->end - p) >= len &&
((this->max_ops -= len) > 0));
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,
"check_range [%p..%p]"