Commit Graph

60 Commits

Author SHA1 Message Date
Noah Misch 4318daecc9 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
2014-02-17 09:33:31 -05:00
Peter Eisentraut 9feeef92fb ecpg: Move function prototype into header file
PGTYPEStimestamp_defmt_scan() was declared twice inside different .c
files, with slightly different prototypes.  Move it into a header file
and correct the prototype.
2013-07-22 21:02:56 -04:00
Michael Meskes a2c1c3308f Initialize day of year value.
There are cases where the day of year value in struct tm is used, but it never
got calculated. Problem found by Coverity scan.
2013-07-19 09:03:45 +02:00
Stephen Frost 551938ae22 Post-pgindent cleanup
Make slightly better decisions about indentation than what pgindent
is capable of.  Mostly breaking out long function calls into one
line per argument, with a few other minor adjustments.

No functional changes- all whitespace.
pgindent ran cleanly (didn't change anything) after.
Passes all regressions.
2013-06-01 09:38:15 -04:00
Bruce Momjian 9af4159fce pgindent run for release 9.3
This is the first run of the Perl-based pgindent script.  Also update
pgindent instructions.
2013-05-29 16:58:43 -04:00
Tom Lane 542eeba269 Fix overflow check in tm2timestamp (this time for sure).
I fixed this code back in commit 841b4a2d5, but didn't think carefully
enough about the behavior near zero, which meant it improperly rejected
1999-12-31 24:00:00.  Per report from Magnus Hagander.
2013-03-04 15:13:31 -05:00
Robert Haas 5d4b60f2f2 Lots of doc corrections.
Josh Kupershmidt
2012-04-23 22:43:09 -04:00
Peter Eisentraut eb990a2b9e Add const qualifier to tzn returned by timestamp2tm()
The tzn value might come from tm->tm_zone, which libc declares as
const, so it's prudent that the upper layers know about this as well.
2012-03-15 21:17:19 +02:00
Peter Eisentraut ad4fb0d0d2 Improve EncodeDateTime and EncodeTimeOnly APIs
Use an explicit argument to tell whether to include the time zone in
the output, rather than using some undocumented pointer magic.
2012-03-14 23:03:34 +02:00
Michael Meskes 59e242a496 Mark variables as const in pgtypeslib if they only carry a format string. 2011-12-18 19:04:19 +01:00
Andrew Dunstan 0f44335122 Miscellaneous cleanup to silence compiler warnings seen on Mingw.
Remove some dead code, conditionally declare some items or call
some code, and fix one or two declarations.
2011-12-10 18:15:15 -05:00
Bruce Momjian 6560407c7d Pgindent run before 9.1 beta2. 2011-06-09 14:32:50 -04:00
Andrew Dunstan c49e4ae1f8 Use non-literal format for possibly non-standard strftime formats.
Per recent -hackers discussion. The formats in question are %G and %V,
and cause warnings on MinGW at least. We assume the ecpg application
knows what it's doing if it passes these formats to the library.
2011-04-28 19:58:49 -04:00
Magnus Hagander 9f2e211386 Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Michael Meskes 2720c57005 Removed some variables no longer needed. 2009-09-03 09:59:20 +00:00
Bruce Momjian d747140279 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
2009-06-11 14:49:15 +00:00
Michael Meskes 0754b391f3 Removed some unneeded variables and comparisons 2009-05-20 16:13:18 +00:00
Michael Meskes 649a1252b7 Added result checks for calls to gmtime(). 2009-02-04 08:51:10 +00:00
Andrew Dunstan 53972b460c Add $PostgreSQL$ markers to a lot of files that were missing them.
This particular batch was just for *.c and *.h file.

The changes were made with the following 2 commands:

find . \( \( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \) -prune \) -o  \( -name '*.[ch]'  \) \( -exec grep -q '\$PostgreSQL' {} \; -o -print \) | while read file ; do head -n 1 < $file | grep -q '^/\*' && echo $file; done | xargs -l sed -i -e '1s/^\// /' -e '1i/*\n * $PostgreSQL:$ \n *'

find . \( \( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \) -prune \) -o  \( -name '*.[ch]'  \) \( -exec grep -q '\$PostgreSQL' {} \; -o -print \) | xargs -l sed -i -e '1i/*\n * $PostgreSQL:$ \n */'
2008-05-17 01:28:26 +00:00
Michael Meskes 02b2bc7907 PGTYPEStimestamp_sub should use the values and not the pointers to substract. 2008-04-10 10:43:35 +00:00
Michael Meskes fefe7034e2 More cleaning up and removed some duplicates. 2007-08-22 08:20:58 +00:00
Michael Meskes 635a0b9a86 - Finished major rewrite to use new protocol version
- Really prepare statements
- Added more regression tests
- Added auto-prepare mode
- Use '$n' for positional variables, '?' is still possible via ecpg option
- Cleaned up the sources a little bit
2007-08-14 10:01:54 +00:00
Michael Meskes d3e131e062 - Changed some whitespacing in connect statement.
- Made some chars const as proposed by Stefan Huehner <stefan@huehner.org>.
- Synced parser and keyword lists.
- Copied two token parsing from backend parser to ecpg parser.
- Also added a test case for this.
2007-03-17 19:25:24 +00:00
Bruce Momjian f99a569a2e pgindent run for 8.2. 2006-10-04 00:30:14 +00:00
Michael Meskes b30da7ba5f Added lots of SoC stuff made by Joachim.
Fixed broken newline on Windows.
Fixed a nasty buffer underrun that only occured when using Informix
no_indicator NULL setting on timestamps and intervals.
2006-08-15 06:40:20 +00:00
Michael Meskes a829da152c Added fixed from the coverity report send in by Joachim Wieland <joe@mcknight.de>
Added missing error handling in a few functions in ecpglib
2006-06-21 10:24:41 +00:00
Bruce Momjian 1dc3498251 Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Tom Lane d7527540f2 <limits.h> is now needed here, for INT_MAX. Per Michael Fuhr. 2005-10-10 01:34:00 +00:00
Tom Lane 313ed1ed94 Fix (hopefully for the last time) problems with datetime values displaying
like '23:59:60' because of fractional-second roundoff problems.  Trying
to control this upstream of the actual display code was hopeless; the right
way is to explicitly round fractional seconds in the display code and then
refigure the results if the fraction rounds up to 1.  Per bug #1927.
2005-10-09 17:21:47 +00:00
Bruce Momjian 3758affc9b More removal of unneeded parentheses. 2005-07-22 19:00:55 +00:00
Bruce Momjian d5f1e08c0c Code spacing improvement, particularly *tm spacing. 2005-07-22 03:46:34 +00:00
Bruce Momjian e6b72d6af6 Update DAYS_PER_MONTH comment.
Add SECS_PER_YEAR and MINS_PER_HOUR macros.
2005-07-21 18:06:13 +00:00
Bruce Momjian a536b2dd80 Add time/date macros for code clarity:
#define DAYS_PER_YEAR   365.25
	#define MONTHS_PER_YEAR 12
	#define DAYS_PER_MONTH  30
	#define HOURS_PER_DAY   24
2005-07-21 03:56:25 +00:00
Bruce Momjian 7f0b690334 Improve comments for AdjustIntervalForTypmod.
Blank line adjustments.
2005-07-12 16:05:12 +00:00
Bruce Momjian 09ff9dbe2b Remove more extraneous parentheses in date/time functions. 2005-05-24 02:09:45 +00:00
Bruce Momjian 4550c1e519 More macro cleanups for date/time. 2005-05-23 21:54:02 +00:00
Bruce Momjian 5ebaae801c Add datetime macros for constants, for clarity:
#define SECS_PER_DAY  86400
#define USECS_PER_DAY INT64CONST(86400000000)
#define USECS_PER_HOUR    INT64CONST(3600000000)
#define USECS_PER_MINUTE INT64CONST(60000000)
#define USECS_PER_SEC INT64CONST(1000000)
2005-05-23 18:56:55 +00:00
Michael Meskes f0299325e4 Added PGTYPEStimestamp_add_interval written by Dave Cramer.
Fixed parsing of defines to make sure they used more than once.
2004-12-23 10:46:10 +00:00
Bruce Momjian b70999d0fd Make TZNAME_GLOBAL for reference to tzname global variable. 2004-09-09 00:24:12 +00:00
Bruce Momjian 15d3f9f6b7 Another pgindent run with lib typedefs added. 2004-08-30 02:54:42 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Michael Meskes 1f87d79142 - Corrected error handling in PGTYPEStimestamp_from_asc.
- Set pgtypeslib version to 1.2.
2004-02-24 16:07:49 +00:00
Michael Meskes 8e6b74e4fd Fixed bug in day of week processing. 2003-10-05 11:12:00 +00:00
Michael Meskes f604b39c2f - Applied some bug fixing patches by Dave Cramer <dave@fastcrypt.com>.
- Added protecting defines to include files.
2003-09-20 09:10:09 +00:00
Tom Lane fc73264005 I don't care whether it's informix-compatible or not: #defining a word
like 'date' in a public header file is a damn fool idea.
2003-09-16 04:32:28 +00:00
Michael Meskes fcdf0e22fc - Added Dave patch for Informix handling of numeric/int conversion.
- Changed all new datatypes to lowercase.
- Fixed rounding bug in numerical types.
2003-09-09 10:46:42 +00:00
Michael Meskes 05f4b03b23 Fixed two bugs in pgtypes library. 2003-09-01 12:37:40 +00:00
Bruce Momjian 089003fb46 pgindent run. 2003-08-04 00:43:34 +00:00
Michael Meskes 25b10fc1e6 Missed two places to replace union member. 2003-08-01 18:19:03 +00:00
Michael Meskes 7a9c074cba - Added some Informix error codes in Informix mode.
- Added just another pgtypeslib function.
2003-08-01 08:21:04 +00:00