blob: c0bf40ab08f9b56c43fd29aba110850e0662bbcc [file] [log] [blame]
Roman Lebedeveb4a9bc2018-07-30 18:58:30 +00001// This file is distributed under the University of Illinois Open Source
2// License. See LICENSE.TXT for details.
3
Roman Lebedevd32c0d12018-10-11 09:09:52 +00004// Test for unsigned-integer-overflow.
Roman Lebedeveb4a9bc2018-07-30 18:58:30 +00005#include <assert.h>
6#include <climits>
7#include <cstddef>
8#include <cstdint>
9#include <cstdlib>
10#include <iostream>
11
Roman Lebedeva0457c02018-10-30 21:59:09 +000012static volatile int32_t Sink;
13static uint8_t Large = UINT8_MAX;
Roman Lebedeveb4a9bc2018-07-30 18:58:30 +000014
15extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
16 assert(Data);
17 if (Size > 0 && Data[0] == 'H') {
18 Sink = 1;
19 if (Size > 1 && Data[1] == 'i') {
20 Sink = 2;
21 if (Size > 2 && Data[2] == '!') {
Roman Lebedevd32c0d12018-10-11 09:09:52 +000022 Large = (unsigned int)Large + 1U; // 'char overflow'.
Roman Lebedeveb4a9bc2018-07-30 18:58:30 +000023 }
24 }
25 }
26 return 0;
27}