Commit graph

3292 commits

Author SHA1 Message Date
Alvaro Herrera
a8e18f3bbf Translation updates 2013-03-31 14:50:55 -03:00
Tom Lane
cf67814054 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:14:28 -05:00
Tom Lane
2228ce6a11 Stamp 8.4.16. 2013-02-04 16:28:55 -05:00
Peter Eisentraut
bae4b9a233 Translation updates 2013-02-03 23:53:08 -05:00
Michael Meskes
060e2435f2 Made ecpglib use translated messages.
Bug reported and fixed by Chen Huajun <chenhj@cn.fujitsu.com>.
2013-01-27 13:53:22 +01:00
Tom Lane
0191095950 Fix one-byte buffer overrun in PQprintTuples().
This bug goes back to the original Postgres95 sources.  Its significance
to modern PG versions is marginal, since we have not used PQprintTuples()
internally in a very long time, and it doesn't seem to have ever been
documented either.  Still, it *is* exposed to client apps, so somebody
out there might possibly be using it.

Xi Wang
2013-01-20 23:44:06 -05:00
Tom Lane
965edcab6e Stamp 8.4.15. 2012-12-03 15:25:45 -05:00
Peter Eisentraut
42720826b9 Translation updates 2012-12-03 07:51:22 -05:00
Tom Lane
25b2499d56 Produce a more useful error message for over-length Unix socket paths.
The length of a socket path name is constrained by the size of struct
sockaddr_un, and there's not a lot we can do about it since that is a
kernel API.  However, it would be a good thing if we produced an
intelligible error message when the user specifies a socket path that's too
long --- and getaddrinfo's standard API is too impoverished to do this in
the natural way.  So insert explicit tests at the places where we construct
a socket path name.  Now you'll get an error that makes sense and even
tells you what the limit is, rather than something generic like
"Non-recoverable failure in name resolution".

Per trouble report from Jeremy Drake and a fix idea from Andrew Dunstan.
2012-11-29 19:57:33 -05:00
Michael Meskes
f22a6edad8 When processing nested structure pointer variables ecpg always expected an
array datatype which of course is wrong.

Applied patch by Muhammad Usama <m.usama@gmail.com> to fix this.
2012-11-29 17:15:52 +01:00
Tom Lane
cd07b5a07f 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:52:58 -04:00
Tom Lane
ed23de2692 Stamp 8.4.14. 2012-09-19 17:55:55 -04:00
Tom Lane
1a36a773a6 Stamp 8.4.13. 2012-08-14 18:45:54 -04:00
Peter Eisentraut
87050703be Translation updates 2012-08-14 16:28:09 -04:00
Peter Eisentraut
32d42fa248 Update copyright year in forgotten places
found by Stefan Kaltenbrunner
2012-06-19 21:33:36 +03:00
Tom Lane
8c9f2dc670 Stamp 8.4.12. 2012-05-31 19:11:47 -04:00
Peter Eisentraut
d871821e47 Translation updates 2012-05-31 23:22:50 +03:00
Tom Lane
0209a10bf8 Stamp 8.4.11. 2012-02-23 17:59:21 -05:00
Tom Lane
4ee9db0cd9 Remove arbitrary limitation on length of common name in SSL certificates.
Both libpq and the backend would truncate a common name extracted from a
certificate at 32 bytes.  Replace that fixed-size buffer with dynamically
allocated string so that there is no hard limit.  While at it, remove the
code for extracting peer_dn, which we weren't using for anything; and
don't bother to store peer_cn longer than we need it in libpq.

This limit was not so terribly unreasonable when the code was written,
because we weren't using the result for anything critical, just logging it.
But now that there are options for checking the common name against the
server host name (in libpq) or using it as the user's name (in the server),
this could result in undesirable failures.  In the worst case it even seems
possible to spoof a server name or user name, if the correct name is
exactly 32 bytes and the attacker can persuade a trusted CA to issue a
certificate in which that string is a prefix of the certificate's common
name.  (To exploit this for a server name, he'd also have to send the
connection astray via phony DNS data or some such.)  The case that this is
a realistic security threat is a bit thin, but nonetheless we'll treat it
as one.

Back-patch to 8.4.  Older releases contain the faulty code, but it's not
a security problem because the common name wasn't used for anything
interesting.

Reported and patched by Heikki Linnakangas

Security: CVE-2012-0867
2012-02-23 15:48:21 -05:00
Peter Eisentraut
94e2495ded Translation updates 2012-02-23 20:33:03 +02:00
Michael Meskes
972e27b2e2 In ecpg removed old leftover check for given connection name.
Ever since we introduced real prepared statements this should work for
different connections. The old solution just emulating prepared statements,
though, wasn't able to handle this.

Closes: #6309
2011-12-18 18:46:23 +01:00
Tom Lane
d08b64581f Stamp 8.4.10. 2011-12-01 16:53:13 -05:00
Peter Eisentraut
3208c64591 Translation updates 2011-12-01 22:47:51 +02:00
Tom Lane
07d306785e Stamp 8.4.9. 2011-09-22 18:03:52 -04:00
Peter Eisentraut
16961f9d68 Translation updates 2011-09-22 22:31:27 +03:00
Peter Eisentraut
c10d1de419 Add missing format argument to ecpg_log() call 2011-09-08 22:10:56 +03:00
Michael Meskes
007e7acab2 Fix brace indentation of commit a6d72ac344 to fit PostgreSQL style. 2011-09-02 09:46:12 +02:00
Michael Meskes
a6d72ac344 In ecpglib restore LC_NUMERIC in case of an error. 2011-09-01 15:35:09 +02:00
Tom Lane
427ba0e714 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:12 -04:00
Tom Lane
c68561cbea 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:30 -04:00
Tom Lane
16976b026a 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:21 -04:00
Tom Lane
276164125c 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:24 -04:00
Tom Lane
383c7ce42b 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:07 -04:00
Tom Lane
e06d1a88f3 Fix PQsetvalue() to avoid possible crash when adding a new tuple.
PQsetvalue unnecessarily duplicated the logic in pqAddTuple, and didn't
duplicate it exactly either --- pqAddTuple does not care what is in the
tuple-pointer array positions beyond the last valid entry, whereas the
code in PQsetvalue assumed such positions would contain NULL.  This led
to possible crashes if PQsetvalue was applied to a PGresult that had
previously been enlarged with pqAddTuple, for instance one built from a
server query.  Fix by relying on pqAddTuple instead of duplicating logic,
and not assuming anything about the contents of res->tuples[res->ntups].

Back-patch to 8.4, where PQsetvalue was introduced.

Andrew Chernow
2011-07-21 12:25:14 -04:00
Michael Meskes
92591c4c8f Adapted expected result for latest change to ecpglib. 2011-07-18 19:12:02 +02:00
Michael Meskes
66593881c6 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:31:57 +02:00
Tom Lane
b36f59e93e 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:03:20 -04:00
Tom Lane
0699d053ba 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:17 -04:00
Tom Lane
891c23ff6e 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:15 -04:00
Marc G. Fournier
7b8b256f08 Tag 8.4.8. 2011-04-15 00:17:14 -03:00
Tom Lane
42e663cc41 Add CheckTableNotInUse calls in DROP TABLE and DROP INDEX.
Recent releases had a check on rel->rd_refcnt in heap_drop_with_catalog,
but failed to cover the possibility of pending trigger events at DROP time.
(Before 8.4 we didn't even check the refcnt.)  When the trigger events were
eventually fired, you'd get "could not open relation with OID nnn" errors,
as in recent report from strk.  Better to throw a suitable error when the
DROP is attempted.

Also add a similar check in DROP INDEX.

Back-patch to all supported branches.
2011-02-15 15:50:06 -05:00
Marc G. Fournier
7df910c7d1 Tag 8.4.7 2011-01-27 22:23:36 -04:00
Andrew Dunstan
370a899696 Allow vpath builds and regression tests to succeed on Mingw. Backpatch to release 8.4 - earlier releases would require more changes and it's not worth the trouble. 2010-12-24 13:32:20 -05:00
Marc G. Fournier
35862ff7f2 Tag 8.4.6. 2010-12-13 22:59:19 -04:00
Peter Eisentraut
9ee4b6f0e1 Translation updates for release 8.4.6 2010-12-13 22:40:15 +02:00
Tom Lane
d4346e15b4 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:07 -04:00
Michael Meskes
a0e02dc1af Applied patch by Itagaki Takahiro to fix incorrect status calculation in
ecpglib. Instead of parsing the statement just as ask the database server.
2010-10-14 17:51:53 +02:00
Marc G. Fournier
2f76a4b5a6 Tag 8.4.5 2010-10-01 10:35:31 -03:00
Peter Eisentraut
1100d1eaff Translation updates for 8.4.5 2010-09-30 23:31:19 +03:00
Tom Lane
76833aeab9 Still more .gitignore cleanup.
Fix overly-enthusiastic ignores, as identified by
git ls-files -i --exclude-standard
2010-09-24 13:48:26 -04:00