diff options
| author | Neil Conway | 2005-05-26 02:14:32 +0000 |
|---|---|---|
| committer | Neil Conway | 2005-05-26 02:14:32 +0000 |
| commit | ab82f60119077b2f6277da8ad4badd1a91980cb5 (patch) | |
| tree | fd02d83dd7ef9c5ccd9039a59bf845f691074a99 /src/include | |
| parent | d1d5c0fe2e7d00024524f752911b2e5ab63516eb (diff) | |
Adjust datetime parsing to be more robust. We now pass the length of the
working buffer into ParseDateTime() and reject too-long input there,
rather than checking the length of the input string before calling
ParseDateTime(). The old method was bogus because ParseDateTime() can use
a variable amount of working space, depending on the content of the
input string (e.g. how many fields need to be NUL terminated). This fixes
a minor stack overrun -- I don't _think_ it's exploitable, although I
won't claim to be an expert.
Along the way, fix a bug reported by Mark Dilger: the working buffer
allocated by interval_in() was too short, which resulted in rejecting
some perfectly valid interval input values. I added a regression test for
this fix.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/utils/datetime.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index cda63ebe6de..f0b5d876b87 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: datetime.h,v 1.45 2003/08/27 23:29:29 tgl Exp $ + * $Id: datetime.h,v 1.45.2.1 2005/05/26 02:14:32 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -294,7 +294,7 @@ extern void GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec, int *tzp); extern void j2date(int jd, int *year, int *month, int *day); extern int date2j(int year, int month, int day); -extern int ParseDateTime(const char *timestr, char *lowstr, +extern int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields); extern int DecodeDateTime(char **field, int *ftype, |
