OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
Noel Gordon
2017/01/03 04:12:39
location: third_party/WebKit/Source/platform/PngFu
scroggo_chromium
2017/01/03 18:24:15
I do not have a strong preference. Added the TODO.
Noel Gordon
2017/01/03 23:57:16
My thinking was if more fuzzers are coming / are b
| |
5 // Compile with: | |
6 // gn gen out/Fuzz '--args=use_libfuzzer=true is_asan=true | |
7 // is_debug=false is_ubsan_security=true' --check | |
8 // ninja -C out/Fuzz png_fuzzer | |
9 // | |
10 // Run with: | |
11 // ./out/Fuzz/png_fuzzer third_party/WebKit/LayoutTests/images/resources/pngfuzz | |
mmoroz
2017/01/03 08:18:36
This command will write new files into `third_part
scroggo_chromium
2017/01/03 18:24:15
Added a comment regarding this.
| |
12 // | |
13 // For more details, see | |
14 // https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/REA DME.md | |
15 | |
16 #include "platform/image-decoders/png/PNGImageDecoder.cpp" | |
17 #include "platform/testing/BlinkFuzzerTestSupport.h" | |
18 #include "public/platform/WebIconSizesParser.h" | |
19 #include "public/platform/WebSize.h" | |
20 #include "public/platform/WebString.h" | |
Noel Gordon
2017/01/03 04:12:39
nit: do you need the following includes?
+#includ
scroggo_chromium
2017/01/03 18:24:15
No. Removed.
| |
21 | |
22 namespace blink { | |
23 | |
24 std::unique_ptr<ImageDecoder> createDecoder( | |
25 ImageDecoder::AlphaOption alphaOption) { | |
26 return WTF::wrapUnique(new PNGImageDecoder( | |
27 alphaOption, ColorBehavior::transformToTargetForTesting(), | |
Noel Gordon
2017/01/03 04:12:39
/me curious: do any of your seed images have a col
scroggo_chromium
2017/01/03 18:24:15
oval.png is sRGB. The rest do not.
| |
28 ImageDecoder::noDecodedImageByteLimit)); | |
29 } | |
30 | |
31 std::unique_ptr<ImageDecoder> createDecoder() { | |
32 return createDecoder(ImageDecoder::AlphaNotPremultiplied); | |
Noel Gordon
2017/01/03 04:12:39
The default code path used by Blink would be _Imag
scroggo_chromium
2017/01/03 18:24:15
Good point. Will default to ImageDecoder::AlphaPre
| |
33 } | |
34 | |
35 // This function will be called by ClusterFuzz. If this does not crash, the | |
36 // test passes. It parses the frame count and then tries to decode each frame | |
37 // in the image. | |
Noel Gordon
2017/01/03 04:12:39
Not sure about the value of this comment. "It par
mmoroz
2017/01/03 08:18:36
Technically, this function will be called by libFu
scroggo_chromium
2017/01/03 18:24:15
Removed the comment.
| |
38 int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | |
39 auto buffer = SharedBuffer::create(data, size); | |
40 auto decoder = createDecoder(); | |
41 decoder->setData(buffer.get(), true); | |
Noel Gordon
2017/01/03 04:12:39
optional: up to you, but I usually write this as
scroggo_chromium
2017/01/03 18:24:15
Done.
| |
42 decoder->frameCount(); | |
43 if (decoder->failed()) | |
44 return 0; | |
45 for (size_t frame = 0; frame < decoder->frameCount(); frame++) { | |
46 decoder->frameBufferAtIndex(frame); | |
47 if (decoder->failed()) | |
48 return 0; | |
49 } | |
50 return 0; | |
51 } | |
52 | |
53 } // namespace blink | |
54 | |
55 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | |
56 return blink::LLVMFuzzerTestOneInput(data, size); | |
57 } | |
58 | |
59 extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { | |
60 blink::InitializeBlinkFuzzTest(argc, argv); | |
61 return 0; | |
62 } | |
OLD | NEW |