Commit graph

3123 commits

Author SHA1 Message Date
Tom Lane
36df743a4a Fix lo_import and lo_export to return useful error messages more often.
I found that these functions tend to return -1 while leaving an empty error
message string in the PGconn, if they suffer some kind of I/O error on the
file.  The reason is that lo_close, which thinks it's executed a perfectly
fine SQL command, clears the errorMessage.  The minimum-change workaround
is to reorder operations here so that we don't fill the errorMessage until
after lo_close.
2012-10-08 21:53:04 -04:00
Tom Lane
891155af45 Stamp 8.3.21. 2012-09-19 17:58:37 -04:00
Tom Lane
3fe78ee807 Stamp 8.3.20. 2012-08-14 18:48:41 -04:00
Peter Eisentraut
8d1f50ed54 Translation updates 2012-08-14 16:24:41 -04:00
Peter Eisentraut
d117d23b1a Update copyright year in forgotten places
found by Stefan Kaltenbrunner
2012-06-19 21:32:51 +03:00
Tom Lane
485e12fb09 Stamp 8.3.19. 2012-05-31 19:14:08 -04:00
Peter Eisentraut
c272fcd7f6 Translation updates 2012-05-31 23:17:11 +03:00
Tom Lane
82345d87c7 Stamp 8.3.18. 2012-02-23 18:01:58 -05:00
Peter Eisentraut
a930226c61 Translation updates 2012-02-23 20:28:42 +02:00
Tom Lane
8ec76895b7 Stamp 8.3.17. 2011-12-01 16:55:48 -05:00
Tom Lane
cef46230dc Stamp 8.3.16. 2011-09-22 18:06:36 -04:00
Peter Eisentraut
3ffe294373 Translation updates 2011-09-22 22:13:43 +03:00
Peter Eisentraut
7f7ed1716d Add missing format argument to ecpg_log() call 2011-09-08 22:13:27 +03:00
Andrew Dunstan
97464012a0 Supply missing brace omitted by commit 12613cb6b8. 2011-09-01 18:01:42 -04:00
Michael Meskes
12613cb6b8 In ecpglib restore LC_NUMERIC in case of an error. 2011-09-01 15:36:34 +02:00
Tom Lane
d3dcf7ae7b Don't assume that "E" response to NEGOTIATE_SSL_CODE means pre-7.0 server.
These days, such a response is far more likely to signify a server-side
problem, such as fork failure.  Reporting "server does not support SSL"
(in sslmode=require) could be quite misleading.  But the results could
be even worse in sslmode=prefer: if the problem was transient and the
next connection attempt succeeds, we'll have silently fallen back to
protocol version 2.0, possibly disabling features the user needs.

Hence, it seems best to just eliminate the assumption that backing off
to non-SSL/2.0 protocol is the way to recover from an "E" response, and
instead treat the server error the same as we would in non-SSL cases.

I tested this change against a pre-7.0 server, and found that there
was a second logic bug in the "prefer" path: the test to decide whether
to make a fallback connection attempt assumed that we must have opened
conn->ssl, which in fact does not happen given an "E" response.  After
fixing that, the code does indeed connect successfully to pre-7.0,
as long as you didn't set sslmode=require.  (If you did, you get
"Unsupported frontend protocol", which isn't completely off base
given the server certainly doesn't support SSL.)

Since there seems no reason to believe that pre-7.0 servers exist anymore
in the wild, back-patch to all supported branches.
2011-08-27 16:37:17 -04:00
Tom Lane
e5d2db5d22 Ensure we discard unread/unsent data when abandoning a connection attempt.
There are assorted situations wherein PQconnectPoll() will abandon a
connection attempt and try again with different parameters (eg, SSL versus
not SSL).  However, the code forgot to discard any pending data in libpq's
I/O buffers when doing this.  In at least one case (server returns E
message during SSL negotiation), there is unread input data which bollixes
the next connection attempt.  I have not checked to see whether this is
possible in the other cases where we close the socket and retry, but it
seems like a matter of good defensive programming to add explicit
buffer-flushing code to all of them.

This is one of several issues exposed by Daniel Farina's report of
misbehavior after a server-side fork failure.

This has been wrong since forever, so back-patch to all supported branches.
2011-08-27 14:16:35 -04:00
Tom Lane
ee27058ac7 Fix previous patch so it also works if not USE_SSL (mea culpa).
On balance, the need to cover this case changes my mind in favor of pushing
all error-message generation duties into the two fe-secure.c routines.
So do it that way.
2011-07-24 23:29:27 -04:00
Tom Lane
5097b83a90 Improve libpq's error reporting for SSL failures.
In many cases, pqsecure_read/pqsecure_write set up useful error messages,
which were then overwritten with useless ones by their callers.  Fix this
by defining the responsibility to set an error message to be entirely that
of the lower-level function when using SSL.

Back-patch to 8.3; the code is too different in 8.2 to be worth the
trouble.
2011-07-24 16:29:30 -04:00
Tom Lane
551458be3a Use OpenSSL's SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This disables an entirely unnecessary "sanity check" that causes failures
in nonblocking mode, because OpenSSL complains if we move or compact the
write buffer.  The only actual requirement is that we not modify pending
data once we've attempted to send it, which we don't.  Per testing and
research by Martin Pihlak, though this fix is a lot simpler than his patch.

I put the same change into the backend, although it's less clear whether
it's necessary there.  We do use nonblock mode in some situations in
streaming replication, so seems best to keep the same behavior in the
backend as in libpq.

Back-patch to all supported releases.
2011-07-24 15:18:12 -04:00
Michael Meskes
201d1b289f Adapted expected result for latest change to ecpglib. 2011-07-18 19:18:27 +02:00
Michael Meskes
1a02ef3c5c Made ecpglib write double with a precision of 15 digits.
Patch by Akira Kurosawa <kurosawa-akira@mxc.nes.nec.co.jp>.
2011-07-18 16:32:42 +02:00
Tom Lane
eb5226e02a Fix assorted issues with build and install paths containing spaces.
Apparently there is no buildfarm critter exercising this case after all,
because it fails in several places.  With this patch, build, install,
check-world, and installcheck-world pass for me on OS X.
2011-06-14 16:24:45 -04:00
Tom Lane
1d6dd87c4b Fix portability bugs in use of credentials control messages for peer auth.
Even though our existing code for handling credentials control messages has
been basically unchanged since 2001, it was fundamentally wrong: it did not
ensure proper alignment of the supplied buffer, and it was calculating
buffer sizes and message sizes incorrectly.  This led to failures on
platforms where alignment padding is relevant, for instance FreeBSD on
64-bit platforms, as seen in a recent Debian bug report passed on by
Martin Pitt (http://bugs.debian.org//cgi-bin/bugreport.cgi?bug=612888).

Rewrite to do the message-whacking using the macros specified in RFC 2292,
following a suggestion from Theo de Raadt in that thread.  Tested by me
on Debian/kFreeBSD-amd64; since OpenBSD and NetBSD document the identical
CMSG API, it should work there too.

Back-patch to all supported branches.
2011-05-30 19:16:22 -04:00
Tom Lane
3b65ffa2bf Fix write-past-buffer-end in ldapServiceLookup().
The code to assemble ldap_get_values_len's output into a single string
wrote the terminating null one byte past where it should.  Fix that,
and make some other cosmetic adjustments to make the code a trifle more
readable and more in line with usual Postgres coding style.

Also, free the "result" string when done with it, to avoid a permanent
memory leak.

Bug report and patch by Albe Laurenz, cosmetic adjustments by me.
2011-05-12 11:57:21 -04:00
Marc G. Fournier
0844f42d41 Tag 8.3.15. 2011-04-15 00:18:15 -03:00
Marc G. Fournier
5370e1a001 Tag 8.3.14 2011-01-27 22:24:47 -04:00
Marc G. Fournier
887e57fe54 Tag 8.3.13. 2010-12-13 23:02:13 -04:00
Peter Eisentraut
54ae5646e3 Translation updates for release 8.3.13 2010-12-13 22:36:03 +02:00
Tom Lane
d109b10edc Fix ecpg test building process to not generate *.dSYM junk on Macs.
The trick is to not try to build executables directly from .c files,
but to always build the intermediate .o files.  For obscure reasons,
Darwin's version of gcc will leave debug cruft behind in the first
case but not the second.  Per complaint from Robert Haas.
2010-10-20 00:55:11 -04:00
Marc G. Fournier
e32229adfa Tag 8.3.12 2010-10-01 10:36:12 -03:00
Peter Eisentraut
65a192c44f Translation updates for 8.3.12 2010-09-30 22:21:39 +03:00
Tom Lane
4f59eed6eb Still more .gitignore cleanup.
Fix overly-enthusiastic ignores, as identified by
git ls-files -i --exclude-standard
2010-09-24 13:48:30 -04:00
Tom Lane
33f41109fa More fixes for libpq's .gitignore file.
The previous patches failed to cover a lot of symlinks that are only
added in platform-specific cases.  Make the lists match what's in the
Makefile for each branch.
2010-09-22 22:32:38 -04:00
Tom Lane
9f5061aa87 Some more gitignore cleanups: cover contrib and PL regression test outputs.
Also do some further work in the back branches, where quite a bit wasn't
covered by Magnus' original back-patch.
2010-09-22 17:23:05 -04:00
Magnus Hagander
60591cde12 Add gitignore files for ecpg regression tests.
Backpatch to 8.2 as that's how far the structure looks the same.
2010-09-22 21:49:13 +02:00
Magnus Hagander
5fff996347 Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:12 +02:00
Michael Meskes
fce23c8780 Data returned by RETURNING clause wasn't correctly processed by ecpg. Patch backported from HEAD. 2010-06-04 10:48:34 +00:00
Marc G. Fournier
c70af4d2fc tag 8.3.11 2010-05-14 03:27:08 +00:00
Peter Eisentraut
0b2f2c57db Translation update 2010-05-13 07:37:42 +00:00
Tom Lane
db01ccc052 Work around a subtle portability problem in use of printf %s format.
Depending on which spec you read, field widths and precisions in %s may be
counted either in bytes or characters.  Our code was assuming bytes, which
is wrong at least for glibc's implementation, and in any case libc might
have a different idea of the prevailing encoding than we do.  Hence, for
portable results we must avoid using anything more complex than just "%s"
unless the string to be printed is known to be all-ASCII.

This patch fixes the cases I could find, including the psql formatting
failure reported by Hernan Gonzalez.  In HEAD only, I also added comments
to some places where it appears safe to continue using "%.*s".
2010-05-08 16:40:14 +00:00
Marc G. Fournier
e842325ac1 tag 8.3.10 2010-03-12 03:40:31 +00:00
Michael Meskes
e51710d1e2 Backport fix from HEAD that makes ecpglib give the right SQLSTATE if the connection disappears. 2010-03-08 13:15:51 +00:00
Magnus Hagander
19a9a5a15a Require hostname to be set when using GSSAPI authentication. Without it,
the GSSAPI libraries crash.

Noted by Zdenek Kotala
2010-03-08 10:01:20 +00:00
Tom Lane
6fe45c9665 Fix a couple of places that would loop forever if attempts to read a stdio file
set ferror() but never set feof().  This is known to be the case for recent
glibc when trying to read a directory as a file, and might be true for other
platforms/cases too.  Per report from Ed L.  (There is more that we ought to
do about his report, but this is one easily identifiable issue.)
2010-03-03 20:31:22 +00:00
Tom Lane
a6d3ec103b Set errno to zero before invoking SSL_read or SSL_write. It appears that
at least in some Windows versions, these functions are capable of returning
a failure indication without setting errno.  That puts us into an infinite
loop if the previous value happened to be EINTR.  Per report from Brendan
Hill.

Back-patch to 8.2.  We could take it further back, but since this is only
known to be an issue on Windows and we don't support Windows before 8.2,
it does not seem worth the trouble.
2009-12-30 03:46:01 +00:00
Marc G. Fournier
f25013104a tag 8.3.9 2009-12-10 03:02:07 +00:00
Magnus Hagander
d724237551 Reject certificates with embedded NULLs in the commonName field. This stops
attacks where an attacker would put <attack>\0<propername> in the field and
trick the validation code that the certificate was for <attack>.

This is a very low risk attack since it reuqires the attacker to trick the
CA into issuing a certificate with an incorrect field, and the common
PostgreSQL deployments are with private CAs, and not external ones. Also,
default mode in 8.4 does not do any name validation, and is thus also not
vulnerable - but the higher security modes are.

Backpatch all the way. Even though versions 8.3.x and before didn't have
certificate name validation support, they still exposed this field for
the user to perform the validation in the application code, and there
is no way to detect this problem through that API.

Security: CVE-2009-4034
2009-12-09 06:37:25 +00:00
Tom Lane
a15cb0652f Remove outside-the-scanner references to "yyleng".
It seems the flex developers have decided to change yyleng from int to size_t.
This has already happened in the latest release of OS X, and will start
happening elsewhere once the next release of flex appears.  Rather than trying
to divine how it's declared in any particular build, let's just remove the one
existing not-very-necessary external usage.

Back-patch to all supported branches; not so much because users in the field
are likely to care about building old branches with cutting-edge flex, as
to keep OSX-based buildfarm members from having problems with old branches.
2009-09-08 04:25:25 +00:00
Marc G. Fournier
e01fdca9f7 Tag 8.3.8 2009-09-04 00:53:29 +00:00