1*62673c43SDokyung Song // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2*62673c43SDokyung Song // See https://llvm.org/LICENSE.txt for license information. 3*62673c43SDokyung Song // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4*62673c43SDokyung Song 5*62673c43SDokyung Song // Test whether the fuzzer can find "SELECT FROM WHERE", given a seed input 6*62673c43SDokyung Song // "SELECTxFROMxWHERE". Without -keep_seed=1, it takes longer time to trigger 7*62673c43SDokyung Song // find the desired string, because the seed input is more likely to be reduced 8*62673c43SDokyung Song // to a prefix of the given input first, losing useful fragments towards the end 9*62673c43SDokyung Song // of the seed input. 10*62673c43SDokyung Song #include <cstdint> 11*62673c43SDokyung Song #include <cstdio> 12*62673c43SDokyung Song #include <cstdlib> 13*62673c43SDokyung Song #include <cstring> 14*62673c43SDokyung Song 15*62673c43SDokyung Song static volatile int Sink = 0; 16*62673c43SDokyung Song LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)17*62673c43SDokyung Songextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 18*62673c43SDokyung Song if (Size > 17) 19*62673c43SDokyung Song return 0; 20*62673c43SDokyung Song 21*62673c43SDokyung Song if (Size >= 6 && Data[0] == 'S' && Data[1] == 'E' && Data[2] == 'L' && 22*62673c43SDokyung Song Data[3] == 'E' && Data[4] == 'C' && Data[5] == 'T') { 23*62673c43SDokyung Song if (Size >= 7 && Data[6] == ' ') { 24*62673c43SDokyung Song if (Size >= 11 && Data[7] == 'F' && Data[8] == 'R' && Data[9] == 'O' && 25*62673c43SDokyung Song Data[10] == 'M') { 26*62673c43SDokyung Song if (Size >= 12 && Data[11] == ' ') { 27*62673c43SDokyung Song if (Size >= 17 && Data[12] == 'W' && Data[13] == 'H' && 28*62673c43SDokyung Song Data[14] == 'E' && Data[15] == 'R' && Data[16] == 'E') { 29*62673c43SDokyung Song fprintf(stderr, "BINGO; Found the target, exiting.\n"); 30*62673c43SDokyung Song exit(1); 31*62673c43SDokyung Song } 32*62673c43SDokyung Song } 33*62673c43SDokyung Song } 34*62673c43SDokyung Song } 35*62673c43SDokyung Song } 36*62673c43SDokyung Song return 0; 37*62673c43SDokyung Song } 38