Coverage Report

Created: 2026-01-15 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/git/oss-fuzz/fuzz-date.c
Line
Count
Source
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
1.78k
{
8
1.78k
  int local;
9
1.78k
  int num;
10
1.78k
  char *str;
11
1.78k
  int16_t tz;
12
1.78k
  timestamp_t ts;
13
1.78k
  enum date_mode_type dmtype;
14
1.78k
  struct date_mode dm;
15
16
1.78k
  if (size <= 4)
17
    /*
18
     * we use the first byte to fuzz dmtype and the
19
     * second byte to fuzz local, then the next two
20
     * bytes to fuzz tz offset. The remainder
21
     * (at least one byte) is fed as input to
22
     * approxidate_careful().
23
     */
24
0
    return 0;
25
26
1.78k
  local = !!(*data++ & 0x10);
27
1.78k
  num = *data++ % DATE_UNIX;
28
1.78k
  if (num >= DATE_STRFTIME)
29
187
    num++;
30
1.78k
  dmtype = (enum date_mode_type)num;
31
1.78k
  size -= 2;
32
33
1.78k
  tz = *data++;
34
1.78k
  tz = (tz << 8) | *data++;
35
1.78k
  size -= 2;
36
37
1.78k
  str = xmemdupz(data, size);
38
39
1.78k
  ts = approxidate_careful(str, &num);
40
1.78k
  free(str);
41
42
1.78k
  dm = date_mode_from_type(dmtype);
43
1.78k
  dm.local = local;
44
1.78k
  show_date(ts, (int)tz, dm);
45
46
1.78k
  date_mode_release(&dm);
47
48
1.78k
  return 0;
49
1.78k
}