mirror of
				https://git.code.sf.net/p/libpng/code.git
				synced 2025-07-10 18:04:09 +02:00 
			
		
		
		
	[libpng16] Defeat optimization that removes reading rows in the fuzzer.
This commit is contained in:
		
							parent
							
								
									90dd185aed
								
							
						
					
					
						commit
						96333b6bea
					
				@ -5,7 +5,7 @@
 | 
				
			|||||||
// Use of this source code is governed by a BSD-style license that may
 | 
					// Use of this source code is governed by a BSD-style license that may
 | 
				
			||||||
// be found in the LICENSE file https://cs.chromium.org/chromium/src/LICENSE
 | 
					// be found in the LICENSE file https://cs.chromium.org/chromium/src/LICENSE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Last changed in libpng 1.6.33beta03 [September 20, 2017]
 | 
					// Last changed in libpng 1.6.33beta03 [September 23, 2017]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// The modifications in 2017 by Glenn Randers-Pehrson include
 | 
					// The modifications in 2017 by Glenn Randers-Pehrson include
 | 
				
			||||||
// 1. addition of a PNG_CLEANUP macro,
 | 
					// 1. addition of a PNG_CLEANUP macro,
 | 
				
			||||||
@ -169,13 +169,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
 | 
				
			|||||||
  int passes = png_set_interlace_handling(png_handler.png_ptr);
 | 
					  int passes = png_set_interlace_handling(png_handler.png_ptr);
 | 
				
			||||||
  png_start_read_image(png_handler.png_ptr);
 | 
					  png_start_read_image(png_handler.png_ptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int max_filter = 0;
 | 
				
			||||||
  for (int pass = 0; pass < passes; ++pass) {
 | 
					  for (int pass = 0; pass < passes; ++pass) {
 | 
				
			||||||
    for (png_uint_32 y = 0; y < height; ++y) {
 | 
					    for (png_uint_32 y = 0; y < height; ++y) {
 | 
				
			||||||
      png_read_row(png_handler.png_ptr,
 | 
					      png_read_row(png_handler.png_ptr,
 | 
				
			||||||
                   static_cast<png_bytep>(png_handler.row_ptr), nullptr);
 | 
					                   static_cast<png_bytep>(png_handler.row_ptr), nullptr);
 | 
				
			||||||
 | 
					      max_filter = png_handler.row_buf[0] > max_filter ?
 | 
				
			||||||
 | 
					        png_handler.row_buf[0] : max_filter;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (max_filter > 5) {
 | 
				
			||||||
 | 
					    PNG_CLEANUP
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  png_read_end(png_handler.png_ptr, png_handler.end_info_ptr);
 | 
					  png_read_end(png_handler.png_ptr, png_handler.end_info_ptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  PNG_CLEANUP
 | 
					  PNG_CLEANUP
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user