Commit Graph

17893 Commits

Author SHA1 Message Date
Tom Lane 98f27aaef3 Fix assorted security-grade bugs in the regex engine. All of these problems
are shared with Tcl, since it's their code to begin with, and the patches
have been copied from Tcl 8.5.0.  Problems:

CVE-2007-4769: Inadequate check on the range of backref numbers allows
crash due to out-of-bounds read.
CVE-2007-4772: Infinite loop in regex optimizer for pattern '($|^)*'.
CVE-2007-6067: Very slow optimizer cleanup for regex with a large NFA
representation, as well as crash if we encounter an out-of-memory condition
during NFA construction.

Part of the response to CVE-2007-6067 is to put a limit on the number of
states in the NFA representation of a regex.  This seems needed even though
the within-the-code problems have been corrected, since otherwise the code
could try to use very large amounts of memory for a suitably-crafted regex,
leading to potential DOS by driving the system into swap, activating a kernel
OOM killer, etc.

Although there are certainly plenty of ways to drive the system into effective
DOS with poorly-written SQL queries, these problems seem worth treating as
security issues because many applications might accept regex search patterns
from untrustworthy sources.

Thanks to Will Drewry of Google for reporting these problems.  Patches by Will
Drewry and Tom Lane.

Security: CVE-2007-4769, CVE-2007-4772, CVE-2007-6067
2008-01-03 20:47:55 +00:00
Tom Lane 20e862155f Forbid ALTER TABLE and CLUSTER when there are pending AFTER-trigger events
in the current backend for the target table.  These operations move tuples
around and would thus invalidate the TIDs stored in the trigger event records.
(We need not worry about events in other backends, since acquiring exclusive
lock should be enough to ensure there aren't any.)  It might be sufficient
to forbid only the table-rewriting variants of ALTER TABLE, but in the absence
of any compelling use-case, let's just be safe and simple.  Per follow-on
investigation of bug #3847, though this is not actually the same problem
reported therein.

Possibly this should be back-patched, but since the case has never been
reported from the field, I didn't bother.
2008-01-02 23:34:42 +00:00
Tom Lane 69528aefbb Insert ARST into the list of known timezone abbreviations. 2008-01-02 21:42:00 +00:00
Tom Lane baecbb9165 Fix plpython's overoptimistic caching of information about the rowtype of
a trigger's target table.  The rowtype could change from one call to the
next, so cope in such cases, while avoiding doing repetitive catalog lookups.
Per bug #3847 from Mark Reid.

Backpatch to 8.2.x.  Likely this fix should go further back, but I can't test
it because I no longer have a machine with a pre-2.5 Python installation.
(Maybe we should rethink that idea about not supporting Python 2.5 in the
older branches.)
2008-01-02 03:10:27 +00:00
Bruce Momjian 14b5eaa236 Correct two more copyrights found by updated script. 2008-01-02 02:42:06 +00:00
Bruce Momjian be6c3b5c2b Modify copyright script to handle cases where there is only one year
in the copyright
2008-01-02 02:36:18 +00:00
Tom Lane 1af45f1d35 Update time zone data files to tzdata release 2007k. 2008-01-01 20:45:10 +00:00
Tom Lane ce9baa06f0 Fix some missed copyright updates. 2008-01-01 20:31:21 +00:00
Bruce Momjian 9098ab9e32 Update copyrights in source tree to 2008. 2008-01-01 19:46:01 +00:00
Tom Lane ac1ae9f2fa Improve a number of elog messages for not-supposed-to-happen cases in btrees,
since these seem to happen after all in corrupted indexes.  Make sure we
supply the index name in all cases, and provide relevant block numbers where
available.  Also consistently identify the index name as such.

Back-patch to 8.2, in hopes that this might help Mason Hale figure out his
problem.
2007-12-31 04:52:05 +00:00
Andrew Dunstan 7284dfe42c Add sanity check to ensure delimiter and quote are different in CSV mode 2007-12-30 14:46:52 +00:00
Peter Eisentraut eea8efe50d may -> might 2007-12-28 12:32:56 +00:00
Michael Meskes 332bed8c6b Sorry, hit the wrong button with my last commit. Here's the correct changelog:
Applied patch send by ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp> to fix bug in connect statement if user name is a variable.
Also fixed test case that didn't detect this.
2007-12-28 11:30:54 +00:00
Michael Meskes 2f86ab7733 *** empty log message *** 2007-12-28 11:25:21 +00:00
Tom Lane 5233dc15cf Improve consistency of error reporting in GUC assign_hook routines. Some
were reporting ERROR for interactive assignments and LOG for other cases,
some were saying nothing for non-interactive cases, and a few did yet other
things.  Make them use a new function GUC_complaint_elevel() to establish
a reasonably uniform policy about how to report.  There are still a few
edge cases such as assign_search_path(), but it's much better than before.
Per gripe from Devrim Gunduz and subsequent discussion.

As noted by Alvaro, it'd be better to fold these custom messages into the
standard "invalid parameter value" complaint from guc.c, perhaps as the DETAIL
field.  However that will require more redesign than seems prudent for 8.3.
This is a relatively safe, low-impact change that we can afford to risk now.
2007-12-28 00:23:23 +00:00
Tom Lane 2e4cb7082c Disallow digits and lower-case ASCII letters as the delimiter in non-CSV
COPY.  We need a restriction here because when the delimiter occurs as a
data character, it is emitted with a backslash, and that will only work
as desired if CopyReadAttributesText() will interpret the backslash sequence
as representing the second character literally.  This is currently untrue
for 'b', 'f', 'n', 'r', 't', 'v', 'x', and octal digits.  For future-proofing
and simplicity of explanation, it seems best to disallow a-z and 0-9.
We must also disallow dot, since "\." by itself would look like copy EOF.
Note: "\N" is by default the null print string, so N would also cause a
problem, but that is already tested for.
2007-12-27 18:28:58 +00:00
Tom Lane f1d1ca9a26 Fix ill-advised usage of x?y:z expressions in errmsg() and errhint() calls.
This prevented gettext from recognizing the strings that need to be
translated.
2007-12-27 17:00:56 +00:00
Tom Lane 16adaf1b80 Swap the order of testing for control characters and for column delimiter in
CopyAttributeOutText(), so that control characters are converted to the
C-style escape sequences even if they happen to be equal to the column
delimiter (as is true by default for tab, for example).  Oversight in my
previous patch to restore pre-8.3 behavior of COPY OUT escaping.  Per report
from Tomas Szepe.
2007-12-27 16:45:22 +00:00
Peter Eisentraut f5f1355dc4 Wording improvements 2007-12-27 13:02:48 +00:00
Bruce Momjian 012786aa1e Update find_typedefs to handle simple 'typedef X' cases, per request
from Tom.
2007-12-21 21:02:41 +00:00
Michael Meskes 51a5921dcc Fixed a few minor glitches pointed out by splint. 2007-12-21 14:33:20 +00:00
Bruce Momjian 7b009a2a9d Modify pgindent to use an external typedefs file rather than included
list.

Remove pgjindent.
2007-12-21 14:20:36 +00:00
Magnus Hagander 3f7f9f594b libpq needs pgsleep on win32 because of the changes to port/open.c. 2007-12-21 09:03:31 +00:00
Magnus Hagander 120d7e18e7 On win32, loop when opening files if sharing- och lock-violation errors
occur. Hopefully, this will make it possible to recover from broken
antivirus and/or backup software that locks our files.
2007-12-20 20:27:53 +00:00
Tom Lane ef6bac3323 When given a nonzero column number, pg_get_indexdef() is only supposed to
print the index key variable or expression for that column.  It was mistakenly
printing ASC/DESC/NULLS FIRST/NULLS LAST decoration too --- and not only for
the target column, but all columns.  Someday we should have an option to
extract that info (and the opclass decoration as well) for a single index
column ... but today is not that day.  Per bug #3829 and subsequent
discussion.
2007-12-20 00:23:19 +00:00
Magnus Hagander 1b1f7e977b Remove unnecessary logo output from msbuild when cleaning ecpg regression
test outputs.
2007-12-19 12:31:35 +00:00
Magnus Hagander 0a6ac0085c Make all msvc build scripts use buildenv.pl, not buildenv.bat.
Andrew Dunstan
2007-12-19 12:29:36 +00:00
Andrew Dunstan 3f2b1db240 Fix thinko in encoding check for chr() 2007-12-18 18:01:48 +00:00
Tom Lane 5335fabe8c Make archiver process report its progress in PS display. Per
proposal by Simon Riggs, though not exactly his patch.
2007-12-18 00:49:34 +00:00
Tom Lane dbc632eb37 Make path_recv() and poly_recv() reject paths/polygons containing no points.
The zero-point case is sensible so far as the data structure is concerned,
so maybe we ought to allow it sometime; but right now the textual input
routines for these types don't allow it, and it seems that not all the
functions for the types are prepared to cope.
Report and patch by Merlin Moncure.
2007-12-18 00:04:08 +00:00
Bruce Momjian 812bf6984b Mention use all configure options when getting pgindent typedefs. 2007-12-17 02:02:48 +00:00
Bruce Momjian 55cfdd4400 Mention installing /contrib libraries for pgindent. 2007-12-17 01:56:43 +00:00
Magnus Hagander 8621c2f6e8 Get dllwrap name from variable instead of hardcoded.
Per complaint from Richard Evans
2007-12-15 16:21:35 +00:00
Peter Eisentraut 5ca3d50db7 Clarify log messages 2007-12-13 11:55:44 +00:00
Bruce Momjian cede2491b8 Mark items needing updating for beta stamping. 2007-12-13 02:02:20 +00:00
Tom Lane df4271fedd Improve the method of localizing column names and other fixed strings in
psql's \d commands and other uses of printQuery().  Previously we would pass
these strings through gettext() and then send them to the server as literals
in the SQL query.  But the code was not set up to handle doubling of quotes in
the strings, causing failure if a translation attempted to use the wrong kind
of quote marks, as indeed is now the case for (at least) the French
translation of \dFp.  Another hazard was that gettext() would translate to
whatever encoding was implied by the client's LC_CTYPE setting, which might be
different from the client_encoding setting, which would probably cause the
server to reject the query as mis-encoded.  The new arrangement is to send the
untranslated ASCII strings to the server, and do the translations inside
printQuery() after the query results come back.  Per report from Guillaume
Lelarge and subsequent discussion.
2007-12-12 21:41:47 +00:00
Tom Lane 286049dbe4 Clean up unportable attempt to use #if inside a macro call, also
faulty code in third arm of #if.  Per buildfarm reports.
2007-12-12 16:53:14 +00:00
Peter Eisentraut a3382de954 Provide a more accurate, detailed log message when the archive command fails. 2007-12-12 09:39:54 +00:00
Alvaro Herrera 230e8962f3 Make CSV column ordering a bit more logical. 2007-12-11 20:07:31 +00:00
Tom Lane 1ebff9ba81 Make documentation of -W options more accurate and uniform. 2007-12-11 19:57:32 +00:00
Tom Lane 1161f1ae14 Remove the long-deprecated -u option from psql, since it does nothing very
useful and confuses people who think it is the same as -U.  (Eventually
we might want to re-introduce it as being an alias for -U, but that should
not happen until the switch has actually not been there for a few releases.)
Likewise in pg_dump and pg_restore.  Per gripe from Robert Treat and
subsequent discussion.
2007-12-11 19:01:06 +00:00
Alvaro Herrera 3bf66d6f1c Extend the format of CSV logs to include the additional information supplied
with the logged event.  CSV logs are now a first-class citizen along plain
text logs in that they carry much of the same information.

Per complaint from depesz on bug #3799.
2007-12-11 15:19:05 +00:00
Magnus Hagander 22867ab986 Use _USE_32BIT_TIME_T when building with MSVC. Also, enforce that it's
used when building addons.

Dave Page
2007-12-11 14:34:43 +00:00
Tom Lane 82ca4d0210 Fix attribution for Rime of the Ancient Mariner (obviously it's been
too long since freshman English :-()
2007-12-10 00:12:31 +00:00
Tom Lane 71e90b0df2 The E. J. Pratt verse used as a tsearch test case is unfortunately still
under copyright in the US and many other places.  Substitute a little
something from a poet who's more safely dead.  Per gripe from Bjorn Munch.
2007-12-09 21:01:18 +00:00
Tom Lane e8191d9f23 Fix bogus prompt for password in -u case. Per gripe from Robert Treat. 2007-12-09 19:04:47 +00:00
Tom Lane 4f9bf7fc5a Fix up the PQconnectionUsedPassword mess: create a separate
PQconnectionNeedsPassword function that tells the right thing for whether to
prompt for a password, and improve PQconnectionUsedPassword so that it checks
whether the password used by the connection was actually supplied as a
connection argument, instead of coming from environment or a password file.
Per bug report from Mark Cave-Ayland and subsequent discussion.
2007-12-09 19:01:40 +00:00
Tom Lane 9fd8843647 Fix mergejoin cost estimation so that we consider the statistical ranges of
the two join variables at both ends: not only trailing rows that need not be
scanned because there cannot be a match on the other side, but initial rows
that will be scanned without possibly having a match.  This allows a more
realistic estimate of startup cost to be made, per recent pgsql-performance
discussion.  In passing, fix a couple of bugs that had crept into
mergejoinscansel: it was not quite up to speed for the task of estimating
descending-order scans, which is a new requirement in 8.3.
2007-12-08 21:05:11 +00:00
Peter Eisentraut cac82bb20c Realign the running text in this file to 79 characters wide. Some other
copy-editing.
2007-12-07 16:44:56 +00:00
Magnus Hagander a0c4ac77ad Disable asserts by default on msvc build (to make it the same
as in unix)
2007-12-06 17:07:37 +00:00