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

Side by Side Diff: testing/libfuzzer/xfa_codec_fuzzer.h

Issue 2386343002: Make sure the fuzzer read size does not go negative. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The PDFium Authors. All rights reserved. 1 // Copyright 2016 The PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ 5 #ifndef TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_
6 #define TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ 6 #define TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "core/fxcodec/codec/ccodec_progressivedecoder.h" 10 #include "core/fxcodec/codec/ccodec_progressivedecoder.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class Reader : public IFX_FileRead { 44 class Reader : public IFX_FileRead {
45 public: 45 public:
46 Reader(const uint8_t* data, size_t size) : m_data(data), m_size(size) {} 46 Reader(const uint8_t* data, size_t size) : m_data(data), m_size(size) {}
47 ~Reader() {} 47 ~Reader() {}
48 48
49 void Release() override {} 49 void Release() override {}
50 50
51 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { 51 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
52 if (offset + size > m_size) 52 if (offset + size > m_size)
53 size = m_size - offset; 53 size = m_size - offset;
54 if (offset > m_size)
Lei Zhang 2016/10/03 21:16:50 Shouldn't we check this first in the function? Sho
dsinclair 2016/10/04 13:11:07 Done.
55 return FALSE;
54 memcpy(buffer, m_data + offset, size); 56 memcpy(buffer, m_data + offset, size);
55 return TRUE; 57 return TRUE;
56 } 58 }
57 59
58 FX_FILESIZE GetSize() override { return static_cast<FX_FILESIZE>(m_size); } 60 FX_FILESIZE GetSize() override { return static_cast<FX_FILESIZE>(m_size); }
59 61
60 private: 62 private:
61 const uint8_t* const m_data; 63 const uint8_t* const m_data;
62 size_t m_size; 64 size_t m_size;
63 }; 65 };
64 }; 66 };
65 67
66 #endif // TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ 68 #endif // TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_
OLDNEW
« 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