mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Added executable msgpack_fuzzer
This commit is contained in:
		| @@ -14,3 +14,4 @@ endif() | |||||||
| include_directories(${CMAKE_CURRENT_LIST_DIR}/src) | include_directories(${CMAKE_CURRENT_LIST_DIR}/src) | ||||||
| add_subdirectory(third-party/catch) | add_subdirectory(third-party/catch) | ||||||
| add_subdirectory(test) | add_subdirectory(test) | ||||||
|  | add_subdirectory(fuzzing) | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								fuzzing/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								fuzzing/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | # ArduinoJson - arduinojson.org | ||||||
|  | # Copyright Benoit Blanchon 2014-2018 | ||||||
|  | # MIT License | ||||||
|  |  | ||||||
|  | add_executable(msgpack_fuzzer | ||||||
|  | 	msgpack_fuzzer.cpp | ||||||
|  | 	fuzzer_main.cpp | ||||||
|  | ) | ||||||
							
								
								
									
										34
									
								
								fuzzing/fuzzer_main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								fuzzing/fuzzer_main.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | |||||||
|  | // ArduinoJson - arduinojson.org | ||||||
|  | // Copyright Benoit Blanchon 2014-2018 | ||||||
|  | // MIT License | ||||||
|  |  | ||||||
|  | // This file is NOT use by Google's OSS fuzz | ||||||
|  | // I only use it to reproduce the bugs found | ||||||
|  |  | ||||||
|  | #include <stdint.h> | ||||||
|  | #include <fstream> | ||||||
|  | #include <iostream> | ||||||
|  | #include <string> | ||||||
|  |  | ||||||
|  | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); | ||||||
|  |  | ||||||
|  | std::string read(const char* path) { | ||||||
|  |   std::ifstream file(path); | ||||||
|  |   return std::string(std::istreambuf_iterator<char>(file), | ||||||
|  |                      std::istreambuf_iterator<char>()); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | int main(int argc, const char* argv[]) { | ||||||
|  |   if (argc < 2) { | ||||||
|  |     std::cerr << "Usage: msgpack_fuzzer files" << std::endl; | ||||||
|  |     return 1; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   for (int i = 1; i < argc; i++) { | ||||||
|  |     std::cout << "Loading " << argv[i] << std::endl; | ||||||
|  |     std::string buffer = read(argv[i]); | ||||||
|  |     LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t*>(buffer.data()), | ||||||
|  |                            buffer.size()); | ||||||
|  |   } | ||||||
|  |   return 0; | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user