/src/imagemagick/oss-fuzz/huffman_decode_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/license/ |
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 | | |
19 | | #include <Magick++/Image.h> |
20 | | |
21 | | #include "utils.cc" |
22 | | |
23 | | namespace MagickCore |
24 | | { |
25 | | extern "C" void AttachBlob(BlobInfo *,const void *,const size_t); |
26 | | } |
27 | | |
28 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data,size_t Size) |
29 | 42 | { |
30 | 42 | Magick::ExceptionInfo |
31 | 42 | *exceptionInfo; |
32 | | |
33 | 42 | Magick::Image |
34 | 42 | image; |
35 | | |
36 | 42 | if (IsInvalidSize(Size)) |
37 | 17 | return(0); |
38 | 25 | MagickCore::AttachBlob(image.image()->blob,(const void *) Data,Size); |
39 | 25 | exceptionInfo=MagickCore::AcquireExceptionInfo(); |
40 | 25 | (void) HuffmanDecodeImage(image.image(),exceptionInfo); |
41 | 25 | (void) MagickCore::DestroyExceptionInfo(exceptionInfo); |
42 | 25 | return(0); |
43 | 42 | } |