Check for offset overflows during sanitize
authorBehdad Esfahbod <behdad@behdad.org>
Sat, 3 Dec 2016 03:51:23 +0000 (19:51 -0800)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 3 Dec 2016 03:51:23 +0000 (19:51 -0800)
src/hb-open-type-private.hh

index 6b64378..66f1c08 100644 (file)
@@ -806,6 +806,7 @@ struct OffsetTo : Offset<OffsetType>
     if (unlikely (!c->check_struct (this))) return_trace (false);
     unsigned int offset = *this;
     if (unlikely (!offset)) return_trace (true);
+    if (unlikely (!c->check_range (base, offset))) return_trace (false);
     const Type &obj = StructAtOffset<Type> (base, offset);
     return_trace (likely (obj.sanitize (c)) || neuter (c));
   }
@@ -816,6 +817,7 @@ struct OffsetTo : Offset<OffsetType>
     if (unlikely (!c->check_struct (this))) return_trace (false);
     unsigned int offset = *this;
     if (unlikely (!offset)) return_trace (true);
+    if (unlikely (!c->check_range (base, offset))) return_trace (false);
     const Type &obj = StructAtOffset<Type> (base, offset);
     return_trace (likely (obj.sanitize (c, user_data)) || neuter (c));
   }