Kevin Lubick | 2be14d3 | 2019-10-21 13:44:48 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 Google, LLC |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "src/core/SkDescriptor.h" |
| 9 | #include "src/core/SkRemoteGlyphCache.h" |
| 10 | |
| 11 | void FuzzSkDescriptorDeserialize(sk_sp<SkData> bytes) { |
| 12 | SkAutoDescriptor aDesc; |
| 13 | bool ok = SkFuzzDeserializeSkDescriptor(bytes, &aDesc); |
| 14 | if (!ok) { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | auto desc = aDesc.getDesc(); |
| 19 | |
| 20 | desc->computeChecksum(); |
| 21 | desc->isValid(); |
| 22 | |
| 23 | // An arbitrary number |
| 24 | uint32_t tagToFind = 117; |
| 25 | |
| 26 | uint32_t ignore; |
| 27 | desc->findEntry(tagToFind, &ignore); |
| 28 | } |
| 29 | |
Kevin Lubick | 493f89e | 2020-09-14 08:37:35 -0400 | [diff] [blame] | 30 | #if defined(SK_BUILD_FOR_LIBFUZZER) |
Kevin Lubick | 2be14d3 | 2019-10-21 13:44:48 -0400 | [diff] [blame] | 31 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
Zepeng Hu | 5b35f21 | 2020-06-14 19:03:34 +0000 | [diff] [blame] | 32 | if (size > 1024) { |
| 33 | return 0; |
| 34 | } |
Kevin Lubick | 2be14d3 | 2019-10-21 13:44:48 -0400 | [diff] [blame] | 35 | auto bytes = SkData::MakeWithoutCopy(data, size); |
Kevin Lubick | a12f6cb | 2019-10-23 07:53:29 -0400 | [diff] [blame] | 36 | FuzzSkDescriptorDeserialize(bytes); |
Kevin Lubick | 2be14d3 | 2019-10-21 13:44:48 -0400 | [diff] [blame] | 37 | return 0; |
| 38 | } |
| 39 | #endif |