/src/libmwaw/src/fuzz/clariswksfuzzer.cpp
Line | Count | Source |
1 | | /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
2 | | |
3 | | /* libmwaw |
4 | | * Version: MPL 2.0 / LGPLv2+ |
5 | | * |
6 | | * The contents of this file are subject to the Mozilla Public License Version |
7 | | * 2.0 (the "License"); you may not use this file except in compliance with |
8 | | * the License or as specified alternatively below. You may obtain a copy of |
9 | | * the License at http://www.mozilla.org/MPL/ |
10 | | * |
11 | | * Software distributed under the License is distributed on an "AS IS" basis, |
12 | | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
13 | | * for the specific language governing rights and limitations under the |
14 | | * License. |
15 | | * |
16 | | * Major Contributor(s): |
17 | | * Copyright (C) 2017 David Tardon (dtardon@redhat.com) |
18 | | * |
19 | | * |
20 | | * All Rights Reserved. |
21 | | * |
22 | | * For minor contributions see the git repository. |
23 | | * |
24 | | * Alternatively, the contents of this file may be used under the terms of |
25 | | * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
26 | | * in which case the provisions of the LGPLv2+ are applicable |
27 | | * instead of those above. |
28 | | */ |
29 | | |
30 | | #include <cstdint> |
31 | | #include <cstdlib> |
32 | | |
33 | | #include <libmwaw/libmwaw.hxx> |
34 | | |
35 | | #include <librevenge-generators/RVNGDummyDrawingGenerator.h> |
36 | | #include <librevenge-generators/RVNGDummyPresentationGenerator.h> |
37 | | #include <librevenge-generators/RVNGDummySpreadsheetGenerator.h> |
38 | | #include <librevenge-generators/RVNGDummyTextGenerator.h> |
39 | | |
40 | | #include <librevenge-stream/librevenge-stream.h> |
41 | | |
42 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
43 | 141k | { |
44 | 141k | librevenge::RVNGStringStream input(data, size); |
45 | 141k | MWAWDocument::Type type = MWAWDocument::MWAW_T_UNKNOWN; |
46 | 141k | MWAWDocument::Kind kind = MWAWDocument::MWAW_K_UNKNOWN; |
47 | 141k | MWAWDocument::isFileFormatSupported(&input, type, kind); |
48 | 141k | switch (kind) { |
49 | 64.6k | case MWAWDocument::MWAW_K_TEXT : { |
50 | 64.6k | librevenge::RVNGDummyTextGenerator generator; |
51 | 64.6k | MWAWDocument::parse(&input, &generator); |
52 | 64.6k | break; |
53 | 0 | } |
54 | 36.3k | case MWAWDocument::MWAW_K_DRAW : |
55 | 40.8k | case MWAWDocument::MWAW_K_PAINT : { |
56 | 40.8k | librevenge::RVNGDummyDrawingGenerator generator; |
57 | 40.8k | MWAWDocument::parse(&input, &generator); |
58 | 40.8k | break; |
59 | 36.3k | } |
60 | 4.83k | case MWAWDocument::MWAW_K_PRESENTATION : { |
61 | 4.83k | librevenge::RVNGDummyPresentationGenerator generator; |
62 | 4.83k | MWAWDocument::parse(&input, &generator); |
63 | 4.83k | break; |
64 | 36.3k | } |
65 | 4.73k | case MWAWDocument::MWAW_K_DATABASE : |
66 | 13.4k | case MWAWDocument::MWAW_K_SPREADSHEET : { |
67 | 13.4k | librevenge::RVNGDummySpreadsheetGenerator generator; |
68 | 13.4k | MWAWDocument::parse(&input, &generator); |
69 | 13.4k | break; |
70 | 4.73k | } |
71 | 17.6k | default : |
72 | 17.6k | break; |
73 | 141k | } |
74 | 141k | return 0; |
75 | 141k | } |
76 | | |
77 | | // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |