/src/wxwidgets/tests/fuzz/zip.cpp
Line | Count | Source |
1 | | /////////////////////////////////////////////////////////////////////////////// |
2 | | // Name: tests/fuzz/zip.cpp |
3 | | // Purpose: ZIP archives reading code fuzzing test |
4 | | // Author: Vadim Zeitlin |
5 | | // Created: 2017-10-24 |
6 | | // Copyright: (c) 2017 Vadim Zeitlin <vadim@wxwidgets.org> |
7 | | /////////////////////////////////////////////////////////////////////////////// |
8 | | |
9 | | #include "wx/log.h" |
10 | | #include "wx/mstream.h" |
11 | | #include "wx/zipstrm.h" |
12 | | |
13 | | #if wxDEBUG_LEVEL |
14 | | |
15 | | static void exitAssertHandler(const wxString& file, |
16 | | int line, |
17 | | const wxString& func, |
18 | | const wxString& cond, |
19 | | const wxString& msg); |
20 | | |
21 | | static volatile wxAssertHandler_t |
22 | | origAssertHandler = wxSetAssertHandler(exitAssertHandler); |
23 | | |
24 | | static void exitAssertHandler(const wxString& file, |
25 | | int line, |
26 | | const wxString& func, |
27 | | const wxString& cond, |
28 | | const wxString& msg) |
29 | 0 | { |
30 | 0 | origAssertHandler(file, line, func, cond, msg); |
31 | |
|
32 | 0 | exit(1); |
33 | 0 | } |
34 | | |
35 | | #endif // wxDEBUG_LEVEL |
36 | | |
37 | | extern "C" int LLVMFuzzerTestOneInput(const wxUint8 *data, size_t size) |
38 | 2.83k | { |
39 | 2.83k | wxLogNull noLog; |
40 | | |
41 | 2.83k | wxMemoryInputStream mis(data, size); |
42 | 2.83k | wxZipInputStream zis(mis); |
43 | 17.4k | while ( wxZipEntry* const ze = zis.GetNextEntry() ) { |
44 | 14.5k | zis.OpenEntry(*ze); |
45 | 14.5k | delete ze; |
46 | 14.5k | } |
47 | | |
48 | 2.83k | return 0; |
49 | 2.83k | } |