File: stb_c_lexer_fuzzer.cpp

package info (click to toggle)
libstb 0.0~git20241109.5c20573%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,520 kB
  • sloc: ansic: 80,776; cpp: 1,506; makefile: 114; sh: 22
file content (74 lines) | stat: -rw-r--r-- 2,081 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#define STB_C_LEX_C_DECIMAL_INTS    Y  
#define STB_C_LEX_C_HEX_INTS        Y
#define STB_C_LEX_C_OCTAL_INTS      Y
#define STB_C_LEX_C_DECIMAL_FLOATS  Y
#define STB_C_LEX_C99_HEX_FLOATS    Y
#define STB_C_LEX_C_IDENTIFIERS     Y
#define STB_C_LEX_C_DQ_STRINGS      Y
#define STB_C_LEX_C_SQ_STRINGS      Y
#define STB_C_LEX_C_CHARS           Y
#define STB_C_LEX_C_COMMENTS        Y
#define STB_C_LEX_CPP_COMMENTS      Y
#define STB_C_LEX_C_COMPARISONS     Y
#define STB_C_LEX_C_LOGICAL         Y
#define STB_C_LEX_C_SHIFTS          Y 
#define STB_C_LEX_C_INCREMENTS      Y
#define STB_C_LEX_C_ARROW           Y
#define STB_C_LEX_EQUAL_ARROW       Y
#define STB_C_LEX_C_BITWISEEQ       Y
#define STB_C_LEX_C_ARITHEQ         Y

#define STB_C_LEX_PARSE_SUFFIXES    Y
#define STB_C_LEX_DECIMAL_SUFFIXES  "uUlL"
#define STB_C_LEX_HEX_SUFFIXES      "lL"
#define STB_C_LEX_OCTAL_SUFFIXES    "lL"
#define STB_C_LEX_FLOAT_SUFFIXES    "uulL"

#define STB_C_LEX_0_IS_EOF             N
#define STB_C_LEX_INTEGERS_AS_DOUBLES  N
#define STB_C_LEX_MULTILINE_DSTRINGS   Y
#define STB_C_LEX_MULTILINE_SSTRINGS   Y
#define STB_C_LEX_USE_STDLIB           N
#define STB_C_LEX_DOLLAR_IDENTIFIER    Y
#define STB_C_LEX_FLOAT_NO_DECIMAL     Y  

#define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES  Y  
#define STB_C_LEX_DISCARD_PREPROCESSOR    Y  
#define STB_C_LEXER_DEFINITIONS         

#define STB_C_LEXER_IMPLEMENTATION
#define STB_C_LEXER_SELF_TEST
#include "../stb_c_lexer.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>


extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
	if(size<3){
		return 0;
	}
	char *input_stream = (char *)malloc(size);
	if (input_stream == NULL){
		return 0;
	}
	memcpy(input_stream, data, size);

	stb_lexer lex;
	char *input_end = input_stream+size-1;
	char *store = (char *)malloc(0x10000);
	int len = 0x10000;
	
	stb_c_lexer_init(&lex, input_stream, input_end, store, len);
	while (stb_c_lexer_get_token(&lex)) {
		if (lex.token == CLEX_parse_error) {
			break;
		}
	}
	
	free(input_stream);
	free(store);
	return 0;
}