1*e4a7a461SVitaly Buka // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2*e4a7a461SVitaly Buka // See https://llvm.org/LICENSE.txt for license information. 3*e4a7a461SVitaly Buka // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4360bf5ffSKostya Serebryany 5360bf5ffSKostya Serebryany // Simple test for a fuzzer. The fuzzer must find the interesting switch value. 6360bf5ffSKostya Serebryany #include <cstddef> 7360bf5ffSKostya Serebryany #include <cstdint> 8360bf5ffSKostya Serebryany #include <cstdio> 9360bf5ffSKostya Serebryany #include <cstdlib> 10360bf5ffSKostya Serebryany #include <cstring> 11360bf5ffSKostya Serebryany 12360bf5ffSKostya Serebryany static volatile int Sink; 13360bf5ffSKostya Serebryany LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)14360bf5ffSKostya Serebryanyextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 15360bf5ffSKostya Serebryany uint32_t v; 16360bf5ffSKostya Serebryany if (Size < 100) return 0; 17360bf5ffSKostya Serebryany memcpy(&v, Data + Size / 2, sizeof(v)); 18360bf5ffSKostya Serebryany switch(v) { 19360bf5ffSKostya Serebryany case 0x47524159: abort(); 20360bf5ffSKostya Serebryany case 0x52474220: abort(); 21360bf5ffSKostya Serebryany default:; 22360bf5ffSKostya Serebryany } 23360bf5ffSKostya Serebryany return 0; 24360bf5ffSKostya Serebryany } 25360bf5ffSKostya Serebryany 26