test/fuzzer: a simple fuzzer using libFuzzer
This commit adds some basic infrastructure for fuzzers, and adds a fuzzer for the CUE sheet parser.
This commit is contained in:
		
							
								
								
									
										26
									
								
								test/fuzzer/FuzzCueParser.cxx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								test/fuzzer/FuzzCueParser.cxx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| #include "playlist/cue/CueParser.hxx" | ||||
| #include "util/IterableSplitString.hxx" | ||||
|  | ||||
| #include <string> | ||||
| #include <string_view> | ||||
|  | ||||
| extern "C" { | ||||
| int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); | ||||
| } | ||||
|  | ||||
| int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) | ||||
| { | ||||
| 	CueParser parser; | ||||
|  | ||||
| 	const std::string_view src{(const char *)data, size}; | ||||
|  | ||||
| 	for (const auto line : IterableSplitString(src, '\n')) { | ||||
| 		parser.Feed(std::string(line).c_str()); | ||||
| 		parser.Get(); | ||||
| 	} | ||||
|  | ||||
| 	parser.Finish(); | ||||
| 	parser.Get(); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann