From 6708c5595fc6babdae0132f8a23cbe3558a58703 Mon Sep 17 00:00:00 2001 From: Michiharu Ariza Date: Wed, 5 Dec 2018 12:51:18 -0800 Subject: [PATCH] fix oss-fuzz issue 11675 (ASSERT: count <= str.len) Also added an additional error check to avail () --- src/hb-cff-interp-common.hh | 18 ++++++++++++++++-- ...inimized-hb-subset-fuzzer-5768186323009536 | Bin 0 -> 337 bytes 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5768186323009536 diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index f2ccc2bdd..9b595ff1a 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -391,8 +391,22 @@ struct SubByteStr inline operator ByteStr (void) const { return ByteStr (str, offset, str.len - offset); } - inline bool avail (unsigned int count=1) const { return str.check_limit (offset, count); } - inline void inc (unsigned int count=1) { offset += count; assert (count <= str.len); } + inline bool avail (unsigned int count=1) const + { + return (!in_error () && str.check_limit (offset, count)); + } + inline void inc (unsigned int count=1) + { + if (likely (!in_error () && (offset <= str.len) && (offset + count <= str.len))) + { + offset += count; + } + else + { + offset = str.len; + set_error (); + } + } inline void set_error (void) { error = true; } inline bool in_error (void) const { return error; } diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5768186323009536 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5768186323009536 new file mode 100644 index 0000000000000000000000000000000000000000..858604d717650226cc56864063bb778518f6233b GIT binary patch literal 337 zcmeYd3Grv(Qvd^JH#acNz`)1|5kV#YqjC|v|4@Js!OFs^AFFCQ2{M8_3&gJO)UZ%i F0RU6-GRgn| literal 0 HcmV?d00001