Skip to content

Commit

Permalink
Do some checks on the timestamp.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Jul 28, 2019
1 parent 98f400d commit ed407e4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions itstar.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ static void datime(unsigned long l, unsigned long r)
{
int y, m, d;

/* If the timestamp is all zeros or all ones, it's invalid. */
if ((l == 0L && r == 0L) ||
(l == 0777777L && r == 0777777L)) {
cdate.tm_year = 0;
return;
}

y = l>>9L;
m = (l>>5L)&017;
d = l&037;
Expand All @@ -468,6 +475,12 @@ static void datime(unsigned long l, unsigned long r)
y -= 2;
}

/* Sanity checking the month and day values. */
if (m == 0)
m = 1;
if (d == 0)
d = 1;

cdate.tm_year=y;
cdate.tm_mon=m-1;
cdate.tm_mday=d;
Expand Down

0 comments on commit ed407e4

Please sign in to comment.