mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	adapt more fuzz targets from zlib, add zip fuzzer, zip dictionary. update uncompress_fuzzer to seed the buffer length separately.
		
			
				
	
	
		
			34 lines
		
	
	
		
			721 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			721 B
		
	
	
	
		
			C
		
	
	
	
	
	
| /* Derived from zlib fuzzers at http://github.com/google/oss-fuzz/tree/master/projects/zlib,
 | |
|  * see ossfuzz.sh for full license text.
 | |
| */
 | |
| 
 | |
| #include <stddef.h>
 | |
| #include <stdint.h>
 | |
| #include <string.h>
 | |
| 
 | |
| #include "miniz.h"
 | |
| 
 | |
| int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
 | |
| {
 | |
|     unsigned long int buffer_length;
 | |
|     unsigned char *buffer = NULL;
 | |
|     int z_status = 0;
 | |
| 
 | |
|     if(size > 4) return 0;
 | |
| 
 | |
|     uint32_t n;
 | |
|     memcpy(&n, data, 4);
 | |
|     buffer_length = n;
 | |
| 
 | |
|     if(buffer_length > (1024 * 256)) return 0;
 | |
| 
 | |
|     buffer = (unsigned char *)malloc(buffer_length);
 | |
| 
 | |
|     z_status = uncompress(buffer, &buffer_length, data + 4, size - 4);
 | |
|     free(buffer);
 | |
| 
 | |
|     if (Z_OK != z_status)
 | |
|         return 0;
 | |
|     return 0;
 | |
| }
 |