/*
  Copyright 2019 Google LLC All rights reserved.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at:

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/


/*
   american fuzzy lop - a trivial program to test libFuzzer target fuzzing.
   ------------------------------------------------------------------------

   Initially written and maintained by Michal Zalewski.
*/

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

// TODO(metzman): Create a test/ directory to store this and other similar
// files.
// 定义一个名为LLVMFuzzerTestOneInput的函数，用于接收一个字节数组（buf）和其大小（size）
int LLVMFuzzerTestOneInput(uint8_t* buf, size_t size) {
    // 检查输入数据的大小是否小于2，如果是，则返回0，表示测试不通过或无需进一步处理
    if (size < 2)
        return 0;

    // 检查输入数据的第一个字节是否为'0'
    if (buf[0] == '0')
        // 如果是'0'，则打印一条消息表示检测到零值
        printf("Looks like a zero to me!\n");
    else
        // 如果不是'0'，则打印一条消息表示检测到非零值
        printf("A non-zero value? How quaint!\n");

    // 函数返回0，表示测试通过或没有发现异常
    return 0;
}
