mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-12-01 18:44:09 +01:00
Add a couple of missing overflow checks (#5901)
* Use hb_unsigned_mul_overflows in CFF2 process_blend. * Check for overflow when computing hb_aat_layout_chain_accelerator_t size.
This commit is contained in:
1 parent
6c5a137cb7
commit
5cbce05a7c
2 files changed
+14
-6
No files matched your search
@@ -987,9 +987,16 @@ struct hb_aat_layout_chain_accelerator_t
|
||||
{
|
||||
unsigned count = chain.get_subtable_count ();
|
||||
|
||||
unsigned size = sizeof (hb_aat_layout_chain_accelerator_t) -
|
||||
HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t) +
|
||||
count * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t);
|
||||
unsigned product;
|
||||
if (unlikely (hb_unsigned_mul_overflows (count,
|
||||
sizeof (hb_accelerate_subtables_context_t::hb_applicable_t), &product)))
|
||||
return nullptr;
|
||||
|
||||
unsigned size;
|
||||
if (unlikely (hb_unsigned_add_overflows (sizeof (hb_aat_layout_chain_accelerator_t) -
|
||||
HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t), product, &size))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* The following is a calloc because when we are collecting subtables,
|
||||
* some of them might be invalid and hence not collect; as a result,
|
||||
|
||||
@@ -281,13 +281,14 @@ struct cff2_cs_opset_t : cs_opset_t<ELEM, OPSET, cff2_cs_interp_env_t<ELEM>, PAR
|
||||
k = env.get_region_count ();
|
||||
n = env.argStack.pop_uint ();
|
||||
/* copy the blend values into blend array of the default values */
|
||||
unsigned int start = env.argStack.get_count () - ((k+1) * n);
|
||||
/* let an obvious error case fail, but note CFF2 spec doesn't forbid n==0 */
|
||||
if (unlikely (start > env.argStack.get_count ()))
|
||||
unsigned int count = env.argStack.get_count ();
|
||||
unsigned int total;
|
||||
if (unlikely (hb_unsigned_mul_overflows (k + 1, n, &total) || total > count))
|
||||
{
|
||||
env.set_error ();
|
||||
return;
|
||||
}
|
||||
unsigned int start = count - total;
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
{
|
||||
const hb_array_t<const ELEM> blends = env.argStack.sub_array (start + n + (i * k), k);
|
||||
|
||||
Reference in new issue
Block a user