Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint:
  fast-import.c::validate_raw_date(): really validate the value
  • Loading branch information
Junio C Hamano committed Oct 8, 2009
2 parents f73b3af + 1cd749c commit f539cfb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1744,19 +1744,22 @@ static int validate_raw_date(const char *src, char *result, int maxlen)
{
const char *orig_src = src;
char *endp;
unsigned long num;

errno = 0;

strtoul(src, &endp, 10);
num = strtoul(src, &endp, 10);
/* NEEDSWORK: perhaps check for reasonable values? */
if (errno || endp == src || *endp != ' ')
return -1;

src = endp + 1;
if (*src != '-' && *src != '+')
return -1;

strtoul(src + 1, &endp, 10);
if (errno || endp == src || *endp || (endp - orig_src) >= maxlen)
num = strtoul(src + 1, &endp, 10);
if (errno || endp == src + 1 || *endp || (endp - orig_src) >= maxlen ||
1400 < num)
return -1;

strcpy(result, orig_src);
Expand Down

0 comments on commit f539cfb

Please sign in to comment.