File tree Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -752,6 +752,7 @@ ETAGS_TARGET = TAGS
752
752
FUZZ_OBJS += oss-fuzz/fuzz-commit-graph.o
753
753
FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
754
754
FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o
755
+ FUZZ_OBJS += oss-fuzz/fuzz-date.o
755
756
.PHONY : fuzz-objs
756
757
fuzz-objs : $(FUZZ_OBJS )
757
758
Original file line number Diff line number Diff line change 1
1
fuzz-commit-graph
2
2
fuzz-pack-headers
3
3
fuzz-pack-idx
4
+ fuzz-date
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 type ;
9
+ int time ;
10
+ int num ;
11
+ char * str ;
12
+ timestamp_t ts ;
13
+ enum date_mode_type dmtype ;
14
+ struct date_mode * dm ;
15
+
16
+ if (size <= 8 )
17
+ {
18
+ return 0 ;
19
+ }
20
+
21
+ type = (* ((int * )data )) % 8 ;
22
+ data += 4 ;
23
+ size -= 4 ;
24
+
25
+ time = abs (* ((int * )data ));
26
+ data += 4 ;
27
+ size -= 4 ;
28
+
29
+ str = (char * )malloc (size + 1 );
30
+ if (!str )
31
+ {
32
+ return 0 ;
33
+ }
34
+ memcpy (str , data , size );
35
+ str [size ] = '\0' ;
36
+
37
+ ts = approxidate_careful (str , & num );
38
+ free (str );
39
+
40
+ switch (type )
41
+ {
42
+ case 0 : default :
43
+ dmtype = DATE_NORMAL ;
44
+ break ;
45
+ case 1 :
46
+ dmtype = DATE_HUMAN ;
47
+ break ;
48
+ case 2 :
49
+ dmtype = DATE_SHORT ;
50
+ break ;
51
+ case 3 :
52
+ dmtype = DATE_ISO8601 ;
53
+ break ;
54
+ case 4 :
55
+ dmtype = DATE_ISO8601_STRICT ;
56
+ break ;
57
+ case 5 :
58
+ dmtype = DATE_RFC2822 ;
59
+ break ;
60
+ case 6 :
61
+ dmtype = DATE_RAW ;
62
+ break ;
63
+ case 7 :
64
+ dmtype = DATE_UNIX ;
65
+ break ;
66
+ }
67
+
68
+ dm = date_mode_from_type (dmtype );
69
+ dm -> local = 1 ;
70
+ show_date (ts , time , dm );
71
+
72
+ date_mode_release (dm );
73
+
74
+ return 0 ;
75
+ }
You can’t perform that action at this time.
0 commit comments