Skip to content

Commit bea3a56

Browse files
authored
Fuzzing: Expose DONT_FAIL_ON_CRC_ERROR as a CMake option and honor it in the rar5 decoder (libarchive#2229)
Hey, the fuzzing infrastructure over at OSSFuzz builds libarchive with the CMake option `-DDONT_FAIL_ON_CRC_ERROR=1`. https://github.com/google/oss-fuzz/blob/e4643b64b3af4932bff23bb87afdfbac2a301969/projects/libarchive/build.sh#L35 This, unfortunatly, does not do anything since it's never been defined as an option. Building the fuzzers with CRC checks disabled should improve fuzzing efficacy a bunch. Thanks!
1 parent ffa43ae commit bea3a56

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,11 @@ IF(APPLE)
21732173
ADD_DEFINITIONS(-Wno-deprecated-declarations)
21742174
ENDIF(APPLE)
21752175

2176+
OPTION(DONT_FAIL_ON_CRC_ERROR "Ignore CRC errors during parsing (For fuzzing)" OFF)
2177+
IF(DONT_FAIL_ON_CRC_ERROR)
2178+
ADD_DEFINITIONS(-DDONT_FAIL_ON_CRC_ERROR=1)
2179+
ENDIF(DONT_FAIL_ON_CRC_ERROR)
2180+
21762181
IF(ENABLE_TEST)
21772182
ADD_CUSTOM_TARGET(run_all_tests)
21782183
ENDIF(ENABLE_TEST)

libarchive/archive_read_support_format_rar5.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,10 +2229,12 @@ static int process_base_block(struct archive_read* a,
22292229
/* Verify the CRC32 of the header data. */
22302230
computed_crc = (uint32_t) crc32(0, p, (int) hdr_size);
22312231
if(computed_crc != hdr_crc) {
2232+
#ifndef DONT_FAIL_ON_CRC_ERROR
22322233
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
22332234
"Header CRC error");
22342235

22352236
return ARCHIVE_FATAL;
2237+
#endif
22362238
}
22372239

22382240
/* If the checksum is OK, we proceed with parsing. */

0 commit comments

Comments
 (0)