14585 Commits

Author SHA1 Message Date
Tom Lane
c07313161f Update release notes for security-related releases in all active branches.
Security: CVE-2007-0555, CVE-2007-0556
2007-02-02 00:11:14 +00:00
Tom Lane
6be54294cb Repair insufficiently careful type checking for SQL-language functions:
we should check that the function code returns the claimed result datatype
every time we parse the function for execution.  Formerly, for simple
scalar result types we assumed the creation-time check was sufficient, but
this fails if the function selects from a table that's been redefined since
then, and even more obviously fails if check_function_bodies had been OFF.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0555
2007-02-02 00:04:16 +00:00
Peter Eisentraut
cf9ca3d2a3 Translation updates 2007-01-31 08:05:43 +00:00
Tom Lane
eea0902ead Correct an old logic error in btree page splitting: when considering a split
exactly at the point where we need to insert a new item, the calculation used
the wrong size for the "high key" of the new left page.  This could lead to
choosing an unworkable split, resulting in "PANIC: failed to add item to the
left sibling" (or "right sibling") failure.  Although this bug has been there
a long time, it's very difficult to trigger a failure before 8.2, since there
was generally a lot of free space on both sides of a chosen split.  In 8.2,
where the user-selected fill factor determines how much free space the code
tries to leave, an unworkable split is much more likely.  Report by Joe
Conway, diagnosis and fix by Heikki Linnakangas.
2007-01-27 20:53:59 +00:00
Tom Lane
d56c800c40 Get pg_utf_mblen(), pg_utf2wchar_with_len(), and utf2ucs() all on the same
page about the maximum UTF8 sequence length we support (4 bytes since 8.1,
3 before that).  pg_utf2wchar_with_len never got updated to support 4-byte
characters at all, and in any case had a buffer-overrun risk in that it
could produce multiple pg_wchars from what mblen claims to be just one UTF8
character.  The only reason we don't have a major security hole is that most
callers allocate worst-case output buffers; the sole exception in released
versions appears to be pre-8.2 iwchareq() (ie, ILIKE), which can be crashed
due to zeroing out its return address --- but AFAICS that can't be exploited
for anything more than a crash, due to inability to control what gets written
there.  Per report from James Russell and Michael Fuhr.

Pre-8.1 the risk is much less, but I still think pg_utf2wchar_with_len's
behavior given an incomplete final character risks buffer overrun, so
back-patch that logic change anyway.

This patch also makes sure that UTF8 sequences exceeding the supported
length (whichever it is) are consistently treated as error cases, rather
than being treated like a valid shorter sequence in some places.
2007-01-24 17:12:47 +00:00
Tatsuo Ishii
43021ef815 Back port patch.
Call srandom() instead of srand().
pgbench calls random() later, so it should have called srandom().
On most platforms except Windows srandom() is actually identical
to srand(), so the bug only bites Windows users.
per bug report from Akio Ishida.
2007-01-13 03:31:12 +00:00
Bruce Momjian
4c884c3ceb Fix markup because older releases couldn't like to refernce pages. REL7_3_17 2007-01-06 04:15:43 +00:00
Bruce Momjian
43a9728290 Fix markup because lc_numeric didn't have an SGML tag in this release. 2007-01-06 03:14:18 +00:00
PostgreSQL Daemon
c41e33f5fa tag for 7.3.17 ... 2007-01-06 02:25:19 +00:00
Tom Lane
3941045cd3 Minor copy-editing for release note updates. 2007-01-05 22:35:22 +00:00
Bruce Momjian
3294607a6a Stamp release 7.3.17. 2007-01-05 20:52:58 +00:00
Bruce Momjian
4f58c0db22 Create release notes for 7.3.17. 2007-01-05 20:02:22 +00:00
Tom Lane
0b29676aa6 Fix regex_fixed_prefix() to cope reasonably well with regex patterns of the
form '^(foo)$'.  Before, these could never be optimized into indexscans.
The recent changes to make psql and pg_dump generate such patterns (for \d
commands and -t and related switches, respectively) therefore represented
a big performance hit for people with large pg_class catalogs, as seen in
recent gripe from Erik Jones.  While at it, be more paranoid about
case-sensitivity checking in multibyte encodings, and fix some other
corner cases in which a regex might be interpreted too liberally.
2007-01-03 22:40:04 +00:00
Tom Lane
d3db2bd80c Repair bug #2839: the various ExecReScan functions need to reset
ps_TupFromTlist in plan nodes that make use of it.  This was being done
correctly in join nodes and Result nodes but not in any relation-scan nodes.
Bug would lead to bogus results if a set-returning function appeared in the
targetlist of a subquery that could be rescanned after partial execution,
for example a subquery within EXISTS().  Bug has been around forever :-(
... surprising it wasn't reported before.
2006-12-26 19:27:26 +00:00
Tom Lane
923ec1a19f Mark to_number() and the numeric-type variants of to_char() as stable, not
immutable, because their results depend on lc_numeric; this is a longstanding
oversight.  We cannot force initdb for this in the back branches, but we can
at least provide correct catalog entries for future installations.
2006-11-28 19:19:25 +00:00
Tom Lane
0951ff33b5 Fix 1-byte buffer overrun when OID exceeds 1 billion. This probably can't
cause any serious harm in normal cases, but if you have gcc buffer overrun
checking turned on, that will notice.  Found by Jack Orenstein.  Problem
was already fixed in CVS HEAD.
2006-11-22 21:13:16 +00:00
Tom Lane
53d7eece13 Stamp 7.3.16. REL7_3_16 2006-10-12 19:42:21 +00:00
Tom Lane
9dd224e3c6 A bit of copy-editing on back-branch release notes. 2006-10-11 20:56:31 +00:00
Tom Lane
7275173636 Fix psql \d commands to behave properly when a pattern using regex | is given.
Formerly they'd emit '^foo|bar$' which is wrong because the anchors are
parsed as part of the alternatives; must emit '^(foo|bar)$' to get expected
behavior.  Same as bug found previously in similar_escape().  Already fixed
in HEAD, this is just back-porting the part of that patch that was a bug fix.
2006-10-10 16:15:42 +00:00
Bruce Momjian
b25ddbb81e Update libpq.rc for 7.3.16 and 7.4.14. Later releases use libpq.rc.in,
which was already updated.
2006-10-10 00:19:51 +00:00
Bruce Momjian
68b856f065 Stamp releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5. 2006-10-09 23:38:14 +00:00
Bruce Momjian
850f5f3287 Update release notes for releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5. 2006-10-09 23:22:58 +00:00
Tom Lane
a9ae4ae8c1 Fix back-branch pg_regress scripts to try the "canonical" expected file if we
tried a variant file from resultmap and it didn't match.  This is already done
in HEAD's C-code version, and is needed because OpenBSD has recently migrated
to a more standard handling of float underflow --- see buildfarm results
from emu.
2006-10-09 01:46:04 +00:00
Tom Lane
4e66f619b0 Fix ancient oversight in psql's \d pattern processing code: when seeing two
quote chars inside quote marks, should emit one quote *and stay in inquotes
mode*.  No doubt the lack of reports of this have something to do with the
poor documentation of the feature ...
2006-10-07 22:22:04 +00:00
Tom Lane
152dbad1eb Clean up rather sloppy fix in HEAD for the ancient bug that CREATE CONVERSION
didn't create a dependency from the new conversion to its schema.  Back-patch
to all supported releases.
2006-08-31 17:32:01 +00:00
Teodor Sigaev
2b3d2717c4 Fix bug introduced by last patch, thanks again to Mario Weilguni <mweilguni@sime.com> 2006-08-08 15:46:31 +00:00
Teodor Sigaev
3da93a0a3b fix bug about modifying value in shared buffer,
what was a reason to corrupt index.
Thank to Mario Weilguni <mweilguni@sime.com> to
discover a bug.
2006-08-07 17:42:54 +00:00
Neil Conway
3c3c610c57 A recent backpatch to 7.3's contrib/ltree got mixed up, putting code in
the wrong place.  This moves it to the right place which allows it to
compile. Patch from Kris Jurka.
2006-07-14 00:32:46 +00:00
Teodor Sigaev
79aabd140d Fix bug corrupting query in gist consistent function.
Thank to Mario Weilguni <mweilguni@sime.com> to discover a bug.
2006-07-11 16:11:06 +00:00
Bruce Momjian
4587cd4280 Fix dbmirror for new backslash escaping:
Martin Pitt [2006-06-16  0:15 +0200]:
> Upstream confirmed my reply in the last mail in [1]: the complete
> escaping logic in DBMirror.pl is seriously screwew.
>
> [1] http://archives.postgresql.org/pgsql-bugs/2006-06/msg00065.php

I finally found some time to debug this, and I think I found a better
patch than the one you proposed. Mine is still hackish and is still a
workaround around a proper quoting solution, but at least it repairs
the parsing without introducing the \' quoting again.

I consider this a band-aid patch to fix the recent security update.
PostgreSQL gurus, would you consider applying this until a better
solution is found for DBMirror.pl?

Martin Pitt        http://www.piware.de
2006-07-06 02:02:36 +00:00
Tom Lane
fe090f0778 Back-patch 7.4-era fix for memory leak with SSL connections due to
missing X509_free() calls.  Per a request from a Red Hat customer;
seems silly for Red Hat to be shipping a patch that's not in upstream.
2006-06-23 14:42:52 +00:00
Tom Lane
9e63275633 Back-port Postgres 7.4 spinlock code into 7.3 branch. This adds
previously-missing spinlock code for x86_64 and ppc64 architectures,
converts the ppc/ppc64 code into gcc inlines, and provides a better
spinlock backoff algorithm on all architectures.  Aside from being
almost identical to the community 7.4 source code, this exact patch
has been in use for awhile in Red Hat's RHEL3 RPMs, so I have pretty
good confidence in it.  Why bother, you ask?  I'm taking pity on a
couple of buildfarm members that have been vainly trying to build 7.3
on these 64-bit architectures.
2006-06-01 23:18:11 +00:00
Tom Lane
7769196fb5 Pre-8.0 branches need to cope with possibility that the system libc knows
about the recent changes in US DST law.  Add a variant horology file, so
that either the old or new rules will be considered valid test results.
2006-06-01 04:10:33 +00:00
Tom Lane
e675978ff5 Stamp release 7.3.15. REL7_3_15 2006-05-21 21:54:31 +00:00
Tom Lane
78e237e1e3 Update release notes for upcoming releases. 2006-05-21 21:50:14 +00:00
Bruce Momjian
502b68876c Stamp releases 7.3.15, 7.4.13, and 8.0.8. 2006-05-21 20:28:22 +00:00
Tom Lane
e6f43f7786 Modify libpq's string-escaping routines to be aware of encoding considerations
and standard_conforming_strings.  The encoding changes are needed for proper
escaping in multibyte encodings, as per the SQL-injection vulnerabilities
noted in CVE-2006-2313 and CVE-2006-2314.  Concurrent fixes are being applied
to the server to ensure that it rejects queries that may have been corrupted
by attempted SQL injection, but this merely guarantees that unpatched clients
will fail rather than allow injection.  An actual fix requires changing the
client-side code.  While at it we have also fixed these routines to understand
about standard_conforming_strings, so that the upcoming changeover to SQL-spec
string syntax can be somewhat transparent to client code.

Since the existing API of PQescapeString and PQescapeBytea provides no way to
inform them which settings are in use, these functions are now deprecated in
favor of new functions PQescapeStringConn and PQescapeByteaConn.  The new
functions take the PGconn to which the string will be sent as an additional
parameter, and look inside the connection structure to determine what to do.
So as to provide some functionality for clients using the old functions,
libpq stores the latest encoding and standard_conforming_strings values
received from the backend in static variables, and the old functions consult
these variables.  This will work reliably in clients using only one Postgres
connection at a time, or even multiple connections if they all use the same
encoding and string syntax settings; which should cover many practical
scenarios.

Clients that use homebrew escaping methods, such as PHP's addslashes()
function or even hardwired regexp substitution, will require extra effort
to fix :-(.  It is strongly recommended that such code be replaced by use of
PQescapeStringConn/PQescapeByteaConn if at all feasible.
2006-05-21 20:20:48 +00:00
Tom Lane
16e77740ea Add a new GUC parameter backslash_quote, which determines whether the SQL
parser will allow "\'" to be used to represent a literal quote mark.  The
"\'" representation has been deprecated for some time in favor of the
SQL-standard representation "''" (two single quote marks), but it has been
used often enough that just disallowing it immediately won't do.  Hence
backslash_quote allows the settings "on", "off", and "safe_encoding",
the last meaning to allow "\'" only if client_encoding is a valid server
encoding.  That is now the default, and the reason is that in encodings
such as SJIS that allow 0x5c (ASCII backslash) to be the last byte of a
multibyte character, accepting "\'" allows SQL-injection attacks as per
CVE-2006-2314 (further details will be published after release).  The
"on" setting is available for backward compatibility, but it must not be
used with clients that are exposed to untrusted input.

Thanks to Akio Ishida and Yasuo Ohgaki for identifying this security issue.
2006-05-21 20:12:20 +00:00
Tom Lane
5c4de67044 Change the backend to reject strings containing invalidly-encoded multibyte
characters in all cases.  Formerly we mostly just threw warnings for invalid
input, and failed to detect it at all if no encoding conversion was required.
The tighter check is needed to defend against SQL-injection attacks as per
CVE-2006-2313 (further details will be published after release).  Embedded
zero (null) bytes will be rejected as well.  The checks are applied during
input to the backend (receipt from client or COPY IN), so it no longer seems
necessary to check in textin() and related routines; any string arriving at
those functions will already have been validated.  Conversion failure
reporting (for characters with no equivalent in the destination encoding)
has been cleaned up and made consistent while at it.

Also, fix a few longstanding errors in little-used encoding conversion
routines: win1251_to_iso, win866_to_iso, euc_tw_to_big5, euc_tw_to_mic,
mic_to_euc_tw were all broken to varying extents.

Patches by Tatsuo Ishii and Tom Lane.  Thanks to Akio Ishida and Yasuo Ohgaki
for identifying the security issues.
2006-05-21 20:07:13 +00:00
Bruce Momjian
583a472f7b Change \' to '', for SQL standards compliance. Backpatch to 7.3, 7.4,
and 8.0.  Later releases already patched.
2006-05-21 19:56:41 +00:00
Tom Lane
506747337b Fix the sense of the test on DH_check()'s return value. This was preventing
custom-generated DH parameters from actually being used by the server.
Found by Michael Fuhr.
2006-05-12 22:45:06 +00:00
Tom Lane
76dc24091f Remove unnecessary .seg/.section directives, per Alan Stange. 2006-05-11 22:00:12 +00:00
Tom Lane
803d61a353 Fix ancient memory leak in PQprintTuples(); our code no longer uses this
routine, but perhaps some applications do.  Found by Martijn van Oosterhout
using Coverity.
2006-04-19 16:16:08 +00:00
Tatsuo Ishii
342fae3dc5 Minor teak. 2006-03-04 12:35:08 +00:00
Tatsuo Ishii
52c4e32d5f Tighten up SJIS byte sequence check. Now we reject invalid SJIS byte
sequence such as "0x95 0x27". Patches from Akio Ishida.
2006-03-04 12:32:59 +00:00
Neil Conway
11b3472672 Fix three Python reference leaks in PLy_traceback(). This would result
in leaking memory when invoking a PL/Python procedure that raises an
exception. Unfortunately this still leaks memory, but at least the
largest leak has been plugged.

This patch also fixes a reference counting mistake in PLy_modify_tuple()
for 8.0, 8.1 and HEAD: we don't actually own a reference to `platt', so
we shouldn't Py_DECREF() it.
2006-02-20 20:10:48 +00:00
Neil Conway
0c853662bd Patch from Marko Kreen:
pgcrypto crypt()/md5 and hmac() leak memory when compiled against
OpenSSL as openssl.c digest ->reset will do two DigestInit calls
against a context.  This happened to work with OpenSSL 0.9.6
but not with 0.9.7+.

Reason for the messy code was that I tried to avoid creating
wrapper structure to transport algorithm info and tried to use
OpenSSL context for it.  The fix is to create wrapper structure.

It also uses newer digest API to avoid memory allocations
on reset with newer OpenSSLs.

Thanks to Daniel Blaisdell for reporting it.
2006-02-18 20:49:02 +00:00
Tom Lane
eb46ad568d Stamp 7.3.14. REL7_3_14 2006-02-12 22:38:54 +00:00
Tom Lane
ee7c1a3fd4 Update release notes. 2006-02-12 22:36:16 +00:00
Tom Lane
118f54d06d Fix bug in SET SESSION AUTHORIZATION that allows unprivileged users to crash
the server, if it has been compiled with Asserts enabled (CVE-2006-0553).
Thanks to Akio Ishida for reporting this problem.
2006-02-12 22:33:47 +00:00