Skip to content

Commit fc47181

Browse files
committed
fuzz: FuzzedFileProvider::write should not return negative value
Doing so can lead to a glibc crash. Also the manpage for fopencookie warns against this: https://man7.org/linux/man-pages/man3/fopencookie.3.html
1 parent ee8c997 commit fc47181

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/test/fuzz/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ ssize_t FuzzedFileProvider::write(void* cookie, const char* buf, size_t size)
566566
SetFuzzedErrNo(fuzzed_file->m_fuzzed_data_provider);
567567
const ssize_t n = fuzzed_file->m_fuzzed_data_provider.ConsumeIntegralInRange<ssize_t>(0, size);
568568
if (AdditionOverflow(fuzzed_file->m_offset, (int64_t)n)) {
569-
return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1;
569+
return 0;
570570
}
571571
fuzzed_file->m_offset += n;
572572
return n;

0 commit comments

Comments
 (0)