Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: testing/libfuzzer/xfa_codec_fuzzer.h

Issue 2386343002: Make sure the fuzzer read size does not go negative. (Closed)
Patch Set: Review feedback Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/libfuzzer/xfa_codec_fuzzer.h
diff --git a/testing/libfuzzer/xfa_codec_fuzzer.h b/testing/libfuzzer/xfa_codec_fuzzer.h
index 6a84ed85725939eb030880f2652dc739dcd085f2..44ead167597a390252ce982606b2179ebea2154f 100644
--- a/testing/libfuzzer/xfa_codec_fuzzer.h
+++ b/testing/libfuzzer/xfa_codec_fuzzer.h
@@ -49,8 +49,11 @@ class XFACodecFuzzer {
void Release() override {}
FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
+ if (offset < 0 || offset > m_size)
Lei Zhang 2016/10/04 18:35:13 Erm, and also shouldn't this be: offset >= m_size
Lei Zhang 2016/10/04 18:35:13 And reading a size of 0 doesn't make sense either.
dsinclair 2016/10/04 18:48:07 Done.
dsinclair 2016/10/04 18:48:07 Done.
+ return FALSE;
if (offset + size > m_size)
size = m_size - offset;
+
memcpy(buffer, m_data + offset, size);
return TRUE;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698