170cbc6dbSSebastian Poeplau // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 270cbc6dbSSebastian Poeplau // See https://llvm.org/LICENSE.txt for license information. 370cbc6dbSSebastian Poeplau // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 470cbc6dbSSebastian Poeplau 570cbc6dbSSebastian Poeplau // Stack overflow test for a fuzzer. The fuzzer must find the string "Hi" and 670cbc6dbSSebastian Poeplau // cause a stack overflow. 770cbc6dbSSebastian Poeplau #include <cstddef> 870cbc6dbSSebastian Poeplau #include <cstdint> 970cbc6dbSSebastian Poeplau 1070cbc6dbSSebastian Poeplau volatile int x; 1170cbc6dbSSebastian Poeplau volatile int y = 1; 1270cbc6dbSSebastian Poeplau infinite_recursion(char * p)13*f0941449SMatt Morehousevoid infinite_recursion(char *p) { 1470cbc6dbSSebastian Poeplau char *buf = nullptr; 1570cbc6dbSSebastian Poeplau 1670cbc6dbSSebastian Poeplau if (y) 1770cbc6dbSSebastian Poeplau infinite_recursion(buf); 1870cbc6dbSSebastian Poeplau 1970cbc6dbSSebastian Poeplau x = 1; 2070cbc6dbSSebastian Poeplau } 2170cbc6dbSSebastian Poeplau LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)2270cbc6dbSSebastian Poeplauextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 2370cbc6dbSSebastian Poeplau if (Size >= 2 && Data[0] == 'H' && Data[1] == 'i') 2470cbc6dbSSebastian Poeplau infinite_recursion(nullptr); 2570cbc6dbSSebastian Poeplau return 0; 2670cbc6dbSSebastian Poeplau } 27