mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Add guard code to protect from buffer overruns on long date/time input
strings. Should go back in and look at doing this a bit more elegantly and (hopefully) cheaper. Probably not too bad anyway, but it seems a shame to scan the strings twice: once for length for this buffer overrun protection, and once to parse the line. Remove use of pow() in date/time handling; was already gone from everything *but* the time data types. Define macros for handling typmod manipulation for date/time types. Should be more robust than all of that brute-force inline code. Rename macros for masking and typmod manipulation to put TIMESTAMP_ or INTERVAL_ in front of the macro name, to reduce the possibility of name space collisions.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.95 2002/06/20 20:29:37 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.96 2002/08/04 06:44:47 thomas Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@ -486,8 +486,8 @@ nabstimein(PG_FUNCTION_ARGS)
|
||||
int nf,
|
||||
ftype[MAXDATEFIELDS];
|
||||
|
||||
if (strlen(str) > MAXDATELEN)
|
||||
elog(ERROR, "Bad (length) abstime external representation '%s'", str);
|
||||
if (strlen(str) >= sizeof(lowstr))
|
||||
elog(ERROR, "Bad abstime external representation (too long) '%s'", str);
|
||||
|
||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
||||
@ -849,8 +849,8 @@ reltimein(PG_FUNCTION_ARGS)
|
||||
ftype[MAXDATEFIELDS];
|
||||
char lowstr[MAXDATELEN + 1];
|
||||
|
||||
if (strlen(str) > MAXDATELEN)
|
||||
elog(ERROR, "Bad (length) reltime external representation '%s'", str);
|
||||
if (strlen(str) >= sizeof(lowstr))
|
||||
elog(ERROR, "Bad reltime external representation (too long) '%s'", str);
|
||||
|
||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0))
|
||||
|
Reference in New Issue
Block a user