/src/imagemagick/oss-fuzz/ping_fuzzer.cc
Line | Count | Source |
1 | | /* |
2 | | Copyright @ 2018 ImageMagick Studio LLC, a non-profit organization |
3 | | dedicated to making software imaging solutions freely available. |
4 | | |
5 | | You may not use this file except in compliance with the License. You may |
6 | | obtain a copy of the License at |
7 | | |
8 | | https://imagemagick.org/script/license.php |
9 | | |
10 | | Unless required by applicable law or agreed to in writing, software |
11 | | distributed under the License is distributed on an "AS IS" BASIS, |
12 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | See the License for the specific language governing permissions and |
14 | | limitations under the License. |
15 | | */ |
16 | | |
17 | | #include <cstdint> |
18 | | #include <cstring> |
19 | | |
20 | | #include <Magick++/Blob.h> |
21 | | #include <Magick++/Image.h> |
22 | | |
23 | | #include "utils.cc" |
24 | | |
25 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) |
26 | 44.0k | { |
27 | 44.0k | if (IsInvalidSize(Size,1)) |
28 | 1 | return(0); |
29 | 44.0k | try |
30 | 44.0k | { |
31 | 44.0k | const Magick::Blob |
32 | 44.0k | blob(Data, Size); |
33 | | |
34 | 44.0k | Magick::Image |
35 | 44.0k | image; |
36 | | |
37 | 44.0k | image.ping(blob); |
38 | 44.0k | } |
39 | | #if defined(BUILD_MAIN) |
40 | | catch (Magick::Exception &e) |
41 | | { |
42 | | std::cout << "Exception when reading: " << e.what() << std::endl; |
43 | | } |
44 | | #else |
45 | 44.0k | catch (Magick::Exception) |
46 | 44.0k | { |
47 | 38.6k | } |
48 | 44.0k | #endif |
49 | 44.0k | return(0); |
50 | 44.0k | } |