File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -750,6 +750,7 @@ SCRIPTS = $(SCRIPT_SH_GEN) \
750
750
ETAGS_TARGET = TAGS
751
751
752
752
FUZZ_OBJS += oss-fuzz/fuzz-commit-graph.o
753
+ FUZZ_OBJS += oss-fuzz/fuzz-date.o
753
754
FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
754
755
FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o
755
756
.PHONY : fuzz-objs
Original file line number Diff line number Diff line change 1
1
fuzz-commit-graph
2
+ fuzz-date
2
3
fuzz-pack-headers
3
4
fuzz-pack-idx
Original file line number Diff line number Diff line change
1
+ #include "git-compat-util.h"
2
+ #include "date.h"
3
+
4
+ int LLVMFuzzerTestOneInput (const uint8_t * data , size_t size );
5
+
6
+ int LLVMFuzzerTestOneInput (const uint8_t * data , size_t size )
7
+ {
8
+ int local ;
9
+ int num ;
10
+ int tz ;
11
+ char * str ;
12
+ int8_t * tmp_data ;
13
+ timestamp_t ts ;
14
+ enum date_mode_type dmtype ;
15
+ struct date_mode * dm ;
16
+
17
+ if (size <= 4 )
18
+ /*
19
+ * we use the first byte to fuzz dmtype and local,
20
+ * then the next three bytes to fuzz tz offset,
21
+ * and the remainder (at least one byte) is fed
22
+ * as end-user input to approxidate_careful().
23
+ */
24
+ return 0 ;
25
+
26
+ local = !!(* data & 0x10 );
27
+ num = * data % DATE_UNIX ;
28
+ if (num >= DATE_STRFTIME )
29
+ num ++ ;
30
+ dmtype = (enum date_mode_type )num ;
31
+ data ++ ;
32
+ size -- ;
33
+
34
+ tmp_data = (int8_t * )data ;
35
+ tz = * tmp_data ++ ;
36
+ tz = (tz << 8 ) | * tmp_data ++ ;
37
+ tz = (tz << 8 ) | * tmp_data ++ ;
38
+ data += 3 ;
39
+ size -= 3 ;
40
+
41
+ str = xmemdupz (data , size );
42
+
43
+ ts = approxidate_careful (str , & num );
44
+ free (str );
45
+
46
+ dm = date_mode_from_type (dmtype );
47
+ dm -> local = local ;
48
+ show_date (ts , tz , dm );
49
+
50
+ date_mode_release (dm );
51
+
52
+ return 0 ;
53
+ }
You can’t perform that action at this time.
0 commit comments