History

fuzzers: always return 0

While LibFuzzer supports rejecting unwanted inputs, it looks like Honggfuzz treats anything other than 0 as fatal error. https://llvm.org/docs/LibFuzzer.html#rejecting-unwanted-inputs https://github.com/google/honggfuzz/blob/348a47213919f14b9453e89a663b1515369bd9a2/libhfuzz/persistent.c#L67 This LOG_F calls exit(EXIT_FAILURE)

Kacper Michajłow committed 2 years ago

Commit e56054b1 parent 76ad8ef2 files · +9 −9Browse files

Unified · Split

2 files
  1. fuzzers/fuzzer_loadfile_direct.c +6 −6
  2. fuzzers/fuzzer_set_property.c +3 −3
fuzzers/fuzzer_loadfile_direct.c+6−6
@@ -27,15 +27,15 @@ · 26 unmodified lines
2727 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
2828 {
2929 if (size <= 1 || data[size - 1] != '\0')
30− return -1;
30+ return 0;
3131
3232 // Exlude data with null bytes inside
3333 if (strlen(data) != size - 1)
34− return -1;
34+ return 0;
3535
3636 #ifdef MPV_PROTO
3737 if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1))
38− return -1;
38+ return 0;
3939 #endif
4040
4141 #if !defined(MPV_PROTO) || defined(MPV_PROTO_FILE)
@@ -49,13 +49,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) · 7 unmodified lines
4949 // Exclude some common paths that are not useful for testing.
5050 // Exclude -
5151 if (size_check == 2 && !strncmp(data_check, "-", 1))
52− return -1;
52+ return 0;
5353 // Exclude relative paths
5454 if (str_startswith(data_check, size_check - 1, ".", 1))
55− return -1;
55+ return 0;
5656 // Exclude absolute paths
5757 if (str_startswith(data_check, size_check - 1, "/", 1))
58− return -1;
58+ return 0;
5959 #endif
6060
6161 mpv_handle *ctx = mpv_create();
fuzzers/fuzzer_set_property.c+3−3
@@ -27,7 +27,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) · 26 unmodified lines
2727 case MPV_FORMAT_STRING:
2828 value_len = strnlen(data, size);
2929 if (!value_len || value_len == size)
30− return -1;
30+ return 0;
3131 value_len += 1;
3232 break;
3333 case MPV_FORMAT_FLAG:
@@ -46,12 +46,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) · 12 unmodified lines
4646
4747 // at least two bytes for the name
4848 if (size < value_len + 2)
49− return -1;
49+ return 0;
5050
5151 const char *name = (const char *)data + value_len;
5252 size_t name_len = strnlen(name, size - value_len);
5353 if (!name_len || name_len != size - value_len - 1)
54− return -1;
54+ return 0;
5555
5656 mpv_handle *ctx = mpv_create();
5757 if (!ctx)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t