Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 private: | 43 private: |
| 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 < 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.
| |
| 53 return FALSE; | |
| 52 if (offset + size > m_size) | 54 if (offset + size > m_size) |
| 53 size = m_size - offset; | 55 size = m_size - offset; |
| 56 | |
| 54 memcpy(buffer, m_data + offset, size); | 57 memcpy(buffer, m_data + offset, size); |
| 55 return TRUE; | 58 return TRUE; |
| 56 } | 59 } |
| 57 | 60 |
| 58 FX_FILESIZE GetSize() override { return static_cast<FX_FILESIZE>(m_size); } | 61 FX_FILESIZE GetSize() override { return static_cast<FX_FILESIZE>(m_size); } |
| 59 | 62 |
| 60 private: | 63 private: |
| 61 const uint8_t* const m_data; | 64 const uint8_t* const m_data; |
| 62 size_t m_size; | 65 size_t m_size; |
| 63 }; | 66 }; |
| 64 }; | 67 }; |
| 65 | 68 |
| 66 #endif // TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ | 69 #endif // TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ |
| OLD | NEW |