1*70cbc6dbSSebastian Poeplau // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2*70cbc6dbSSebastian Poeplau // See https://llvm.org/LICENSE.txt for license information. 3*70cbc6dbSSebastian Poeplau // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4*70cbc6dbSSebastian Poeplau 5*70cbc6dbSSebastian Poeplau // Stack overflow test for a fuzzer. The fuzzer must find the string "Hi" and 6*70cbc6dbSSebastian Poeplau // cause a stack overflow. 7*70cbc6dbSSebastian Poeplau #include <cstddef> 8*70cbc6dbSSebastian Poeplau #include <cstdint> 9*70cbc6dbSSebastian Poeplau 10*70cbc6dbSSebastian Poeplau volatile int x; 11*70cbc6dbSSebastian Poeplau volatile int y = 1; 12*70cbc6dbSSebastian Poeplau 13*70cbc6dbSSebastian Poeplau int infinite_recursion(char *p) { 14*70cbc6dbSSebastian Poeplau char *buf = nullptr; 15*70cbc6dbSSebastian Poeplau 16*70cbc6dbSSebastian Poeplau if (y) 17*70cbc6dbSSebastian Poeplau infinite_recursion(buf); 18*70cbc6dbSSebastian Poeplau 19*70cbc6dbSSebastian Poeplau x = 1; 20*70cbc6dbSSebastian Poeplau } 21*70cbc6dbSSebastian Poeplau 22*70cbc6dbSSebastian Poeplau extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 23*70cbc6dbSSebastian Poeplau if (Size >= 2 && Data[0] == 'H' && Data[1] == 'i') 24*70cbc6dbSSebastian Poeplau infinite_recursion(nullptr); 25*70cbc6dbSSebastian Poeplau return 0; 26*70cbc6dbSSebastian Poeplau } 27