-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
fuzz-commit-graph | ||
fuzz-pack-headers | ||
fuzz-pack-idx | ||
fuzz-date |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "git-compat-util.h" | ||
#include "date.h" | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) | ||
{ | ||
if (size <= 8) | ||
{ | ||
return 0; | ||
} | ||
|
||
int type = (*((int *)data)) % 8; | ||
Check failure on line 13 in oss-fuzz/fuzz-date.c GitHub Actions / linux-musl (alpine)
Check failure on line 13 in oss-fuzz/fuzz-date.c GitHub Actions / linux-TEST-vars (ubuntu-20.04)
Check failure on line 13 in oss-fuzz/fuzz-date.c GitHub Actions / linux-sha256 (ubuntu-latest)
Check failure on line 13 in oss-fuzz/fuzz-date.c GitHub Actions / linux-asan-ubsan (ubuntu-latest)
Check failure on line 13 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc-default (ubuntu-latest)
Check failure on line 13 in oss-fuzz/fuzz-date.c GitHub Actions / linux-leaks (ubuntu-latest)
Check failure on line 13 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc (ubuntu-20.04)
Check failure on line 13 in oss-fuzz/fuzz-date.c GitHub Actions / pedantic (fedora)
|
||
data += 4; | ||
size -= 4; | ||
|
||
int time = abs(*((int *)data)); | ||
Check failure on line 17 in oss-fuzz/fuzz-date.c GitHub Actions / linux-musl (alpine)
Check failure on line 17 in oss-fuzz/fuzz-date.c GitHub Actions / linux-TEST-vars (ubuntu-20.04)
Check failure on line 17 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc-default (ubuntu-latest)
Check failure on line 17 in oss-fuzz/fuzz-date.c GitHub Actions / linux-leaks (ubuntu-latest)
Check failure on line 17 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc (ubuntu-20.04)
Check failure on line 17 in oss-fuzz/fuzz-date.c GitHub Actions / pedantic (fedora)
|
||
data += 4; | ||
size -= 4; | ||
|
||
char *str = (char *)malloc(size+1); | ||
Check failure on line 21 in oss-fuzz/fuzz-date.c GitHub Actions / linux-musl (alpine)
Check failure on line 21 in oss-fuzz/fuzz-date.c GitHub Actions / linux-TEST-vars (ubuntu-20.04)
Check failure on line 21 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc-default (ubuntu-latest)
Check failure on line 21 in oss-fuzz/fuzz-date.c GitHub Actions / linux-leaks (ubuntu-latest)
Check failure on line 21 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc (ubuntu-20.04)
Check failure on line 21 in oss-fuzz/fuzz-date.c GitHub Actions / pedantic (fedora)
|
||
if (str == NULL) | ||
{ | ||
return 0; | ||
} | ||
memcpy(str, data, size); | ||
str[size] = '\0'; | ||
|
||
int errno; | ||
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-musl (alpine)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-musl (alpine)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-TEST-vars (ubuntu-20.04)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-TEST-vars (ubuntu-20.04)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-sha256 (ubuntu-latest)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-asan-ubsan (ubuntu-latest)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc-default (ubuntu-latest)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc-default (ubuntu-latest)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-leaks (ubuntu-latest)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-leaks (ubuntu-latest)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc (ubuntu-20.04)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc (ubuntu-20.04)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / pedantic (fedora)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / pedantic (fedora)
Check failure on line 29 in oss-fuzz/fuzz-date.c GitHub Actions / linux32 (daald/ubuntu32:xenial)
|
||
timestamp_t ts = approxidate_careful(str, &errno); | ||
free(str); | ||
|
||
enum date_mode_type dmtype; | ||
Check failure on line 33 in oss-fuzz/fuzz-date.c GitHub Actions / linux-musl (alpine)
Check failure on line 33 in oss-fuzz/fuzz-date.c GitHub Actions / linux-TEST-vars (ubuntu-20.04)
Check failure on line 33 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc-default (ubuntu-latest)
Check failure on line 33 in oss-fuzz/fuzz-date.c GitHub Actions / linux-leaks (ubuntu-latest)
Check failure on line 33 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc (ubuntu-20.04)
Check failure on line 33 in oss-fuzz/fuzz-date.c GitHub Actions / pedantic (fedora)
|
||
switch(type) | ||
{ | ||
case 0: default: | ||
dmtype = DATE_NORMAL; | ||
break; | ||
case 1: | ||
dmtype = DATE_HUMAN; | ||
break; | ||
case 2: | ||
dmtype = DATE_SHORT; | ||
break; | ||
case 3: | ||
dmtype = DATE_ISO8601; | ||
break; | ||
case 4: | ||
dmtype = DATE_ISO8601_STRICT; | ||
break; | ||
case 5: | ||
dmtype = DATE_RFC2822; | ||
break; | ||
case 6: | ||
dmtype = DATE_RAW; | ||
break; | ||
case 7: | ||
dmtype = DATE_UNIX; | ||
break; | ||
} | ||
|
||
struct date_mode *dm = date_mode_from_type(dmtype); | ||
Check failure on line 62 in oss-fuzz/fuzz-date.c GitHub Actions / linux-musl (alpine)
Check failure on line 62 in oss-fuzz/fuzz-date.c GitHub Actions / linux-TEST-vars (ubuntu-20.04)
Check failure on line 62 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc-default (ubuntu-latest)
Check failure on line 62 in oss-fuzz/fuzz-date.c GitHub Actions / linux-leaks (ubuntu-latest)
Check failure on line 62 in oss-fuzz/fuzz-date.c GitHub Actions / linux-gcc (ubuntu-20.04)
Check failure on line 62 in oss-fuzz/fuzz-date.c GitHub Actions / pedantic (fedora)
|
||
dm->local = 1; | ||
show_date(ts, time, dm); | ||
|
||
date_mode_release(dm); | ||
|
||
return 0; | ||
} |