mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Fix handling of wide datetime input/output.
Many server functions use the MAXDATELEN constant to size a buffer for parsing or displaying a datetime value. It was much too small for the longest possible interval output and slightly too small for certain valid timestamp input, particularly input with a long timezone name. The long input was rejected needlessly; the long output caused interval_out() to overrun its buffer. ECPG's pgtypes library has a copy of the vulnerable functions, which bore the same vulnerabilities along with some of its own. In contrast to the server, certain long inputs caused stack overflow rather than failing cleanly. Back-patch to 8.4 (all supported versions). Reported by Daniel Schüssler, reviewed by Tom Lane. Security: CVE-2014-0063
This commit is contained in:
@@ -188,12 +188,17 @@ struct tzEntry;
|
||||
#define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
|
||||
#define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_ALL_SECS_M)
|
||||
|
||||
#define MAXDATELEN 63 /* maximum possible length of an input date
|
||||
* string (not counting tr. null) */
|
||||
#define MAXDATEFIELDS 25 /* maximum possible number of fields in a date
|
||||
* string */
|
||||
#define TOKMAXLEN 10 /* only this many chars are stored in
|
||||
* datetktbl */
|
||||
/*
|
||||
* Working buffer size for input and output of interval, timestamp, etc.
|
||||
* Inputs that need more working space will be rejected early. Longer outputs
|
||||
* will overrun buffers, so this must suffice for all possible output. As of
|
||||
* this writing, interval_out() needs the most space at ~90 bytes.
|
||||
*/
|
||||
#define MAXDATELEN 128
|
||||
/* maximum possible number of fields in a date string */
|
||||
#define MAXDATEFIELDS 25
|
||||
/* only this many chars are stored in datetktbl */
|
||||
#define TOKMAXLEN 10
|
||||
|
||||
/* keep this struct small; it gets used a lot */
|
||||
typedef struct
|
||||
|
Reference in New Issue
Block a user