Fix handling of wide datetime input/output.
authorNoah Misch
Mon, 17 Feb 2014 14:33:31 +0000 (09:33 -0500)
committerNoah Misch
Mon, 17 Feb 2014 14:33:32 +0000 (09:33 -0500)
commite4a4fa22352b062bc3548c91fa9bfc6caed7b073
tree65e1c82e94c7f3fc74618e07a2a96e427f6adad2
parente1e0a4d791292ebe9572451a6cf49fb0ccb320c7
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
src/include/utils/datetime.h
src/interfaces/ecpg/pgtypeslib/datetime.c
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt_common.c
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/pgtypeslib/timestamp.c
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.stdout
src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc
src/test/regress/expected/interval.out
src/test/regress/sql/interval.sql