llvm/libc/fuzzing/string/strstr_fuzz.cpp

//===-- strstr_fuzz.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// Fuzzing test for llvm-libc strstr implementation.
///
//===----------------------------------------------------------------------===//

#include "src/string/strlen.h"
#include "src/string/strstr.h"
#include <stddef.h>
#include <stdint.h>

// Simple loop to compare two strings up to a size n.
static int simple_memcmp(const char *left, const char *right, size_t n) {}

// The general structure is to take the value of the first byte, set size1 to
// that value, and add the null terminator. size2 will then contain the rest of
// the bytes in data.
// For example, with inputs (data={2, 6, 4, 8, 0}, size=5):
//         size1: data[0] = 2
//         data1: {2, 6} + '\0' = {2, 6, '\0'}
//         size2: size - size1 = 3
//         data2: {4, 8, '\0'}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {}