fix: address PR review — fuzz target fixes, UBSan, CI improvements
Critical fixes: - Add missing #include <string.h> to 5 fuzz targets (wouldn't compile with GCC14+/Clang16+) - Fix fuzz_metadata_from_buf.c OOB read: guard size >= sizeof(int) + FILE_METADATA_WIRE_SIZE - Add Clang compiler check for ENABLE_FUZZ in CMakeLists.txt (fail fast at configure time) - Add fuzz-build CI job (install clang, build all 6 fuzz targets with ENABLE_FUZZ=ON) Warning fixes: - Add UBSan to sanitizer CI matrix (address + undefined) - Remove tautological test_property_glob_consistency (pure/deterministic function) - Use fixed seed srand(42) instead of srand(time(NULL)) for reproducible property tests - Add valid-header + truncated-instructions delta robustness test (exercises instruction-loop error paths) - Fix lcov --remove to exclude '*/_deps/*' (xxhash coverage pollution) - Add comment explaining FASTSYNC_UNDER_VALGRIND skip in test_file.c - Update .gitignore for build-*/ directories
This commit is contained in:
@@ -126,6 +126,35 @@ static void test_delta_signature_deserialize_truncated() {
|
||||
delta_signature_destroy(sig);
|
||||
}
|
||||
|
||||
static void test_delta_deserialize_truncated_instructions() {
|
||||
// Create a real delta with 2 LITERAL instructions, serialize, then
|
||||
// truncate after the header so the instruction-loop error paths are
|
||||
// exercised (earlier tests with tiny buffers die at the 12-byte
|
||||
// header guard and never reach the instruction decoder).
|
||||
char old_data[4096], new_data[4096];
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
old_data[i] = (char)(i % 256);
|
||||
new_data[i] = old_data[i];
|
||||
}
|
||||
// Two small changes to produce 2 LITERAL instructions
|
||||
new_data[100] = 'X';
|
||||
new_data[200] = 'Y';
|
||||
|
||||
DeltaSignature* sig = delta_signature_create(old_data, 4096, 1024);
|
||||
Delta* delta = delta_compute(new_data, 4096, sig, 1024);
|
||||
Data* serialized = delta_serialize(delta);
|
||||
EXPECT_NOT_NULL(serialized);
|
||||
|
||||
// Truncate to include the header (12 bytes) + partial first instruction
|
||||
serialized->size = 14;
|
||||
const Delta* result = delta_deserialize(serialized);
|
||||
EXPECT_NULL(result);
|
||||
|
||||
data_destroy(serialized);
|
||||
delta_destroy(delta);
|
||||
delta_signature_destroy(sig);
|
||||
}
|
||||
|
||||
static void test_delta_apply_null() {
|
||||
const void* result = delta_apply(NULL, 0, NULL, 0);
|
||||
EXPECT_NULL(result);
|
||||
@@ -177,6 +206,7 @@ void test_robustness() {
|
||||
test_delta_deserialize_truncated();
|
||||
test_delta_deserialize_empty();
|
||||
test_delta_deserialize_garbage();
|
||||
test_delta_deserialize_truncated_instructions();
|
||||
test_delta_signature_deserialize_truncated();
|
||||
test_delta_apply_null();
|
||||
test_protocol_receive_n_data_closed_pipe();
|
||||
|
||||
Reference in New Issue
Block a user