summaryrefslogtreecommitdiff
path: root/src/interfaces
AgeCommit message (Collapse)Author
2012-03-08ecpg: Fix off-by-one error in memory copyingPeter Eisentraut
In a rare case, one byte past the end of memory belonging to the sqlca_t structure would be written to. found by Coverity
2012-03-08ecpg: Fix rare memory leaksPeter Eisentraut
found by Coverity
2012-03-07libpq: Fix memory leakPeter Eisentraut
If a client encoding is specified as a connection parameter (or environment variable), internal storage allocated for it would never be freed.
2012-03-06libpq: Small code clarification, and avoid casting away constPeter Eisentraut
2012-03-02ecpg: Clean up some const usagePeter Eisentraut
2012-02-23Remove arbitrary limitation on length of common name in SSL certificates.Tom Lane
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-19In ecpglib rewrote code that used strtok_r to not use library functionsMichael Meskes
anymore. This way we don't have to worry which compiler on which OS offers which version of strtok.
2012-02-18gcc on Windows does not know about strtok_s.Michael Meskes
2012-02-18Windows doesn't have strtok_r, so let's use strtok_s instead.Michael Meskes
2012-02-18Make sure all connection paramters are used in call to PQconnectdbParams.Michael Meskes
2012-02-13Do not use the variable name when defining a varchar structure in ecpg.Michael Meskes
With a unique counter being added anyway, there is no need anymore to have the variable name listed, too.
2012-02-06Allow the connection keyword array to carry all seven items in ecpglib.Michael Meskes
2012-02-06fe-misc.c depends on pg_config_paths.hAlvaro Herrera
Declare this in Makefile to avoid failures in parallel compiles. Author: Lionel Elie Mamane
2012-02-04Applied Peter's patch to PQconnectdbParams in ecpglib instead of the oldMichael Meskes
PQconectdb.
2012-02-02ecpg: Improve test buildingPeter Eisentraut
Further improve on commit c75e1436467f32a06b5ab9d594d2a390e7f4594d. Instead of building both .o files and binaries in the same make rule, just rely on the normal .c -> .o rule. This will ensure that dependency tracking is used when enabled. To do this, disable the implicit direct .c -> binary rule globally, which will also prevent the original problem (*.dSYM junk) from reappearing elsewhere.
2012-02-01Properly free the sslcompression field in PGconnMagnus Hagander
Marko Kreen
2012-01-30Use abort() instead of exit() to abort library functionsPeter Eisentraut
In some hopeless situations, certain library functions in libpq and libpgport quit the program. Use abort() for that instead of exit(), so we don't interfere with the normal exit codes the program might use, we clearly signal the abnormal termination, and the caller has a chance of catching the termination. This was originally pointed out by Debian's Lintian program.
2012-01-05Ecpglib stores variables that are used in DECLARE statements in a global list.Michael Meskes
This list is now freed when the last connection has been closed. Closes: #6366
2012-01-04Made code in ecpg better readable.Michael Meskes
2012-01-02pg_regress: Replace exit_nicely() with exit() plus atexit() hookPeter Eisentraut
2012-01-01Update copyright notices for year 2012.Bruce Momjian
2011-12-27Standardize treatment of strcmp() return valuePeter Eisentraut
Always compare the return value to 0, don't use cute tricks like if (!strcmp(...)).
2011-12-22Don't forget to de-escape the password field in .pgpass.Robert Haas
This has been broken just about forever (or more specifically, commit 7f4981f4af1700456f98ac3f2b2d84959919ec81) and nobody noticed until Richard Huxton reported it recently. Analysis and fix by Ross Reedstrom, although I didn't use his patch. This doesn't seem important enough to back-patch and is mildly backward incompatible, so I'm just doing this in master.
2011-12-18Mark variables as const in pgtypeslib if they only carry a format string.Michael Meskes
2011-12-18Added test for cursor handling on different connections to regression testMichael Meskes
suite for ecpg.
2011-12-18In ecpg removed old leftover check for given connection name.Michael Meskes
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-10Miscellaneous cleanup to silence compiler warnings seen on Mingw.Andrew Dunstan
Remove some dead code, conditionally declare some items or call some code, and fix one or two declarations.
2011-12-10Enable compiling with the mingw-w64 32 bit compiler.Andrew Dunstan
Original patch by Lars Kanis, reviewed by Nishiyama Tomoaki and tweaked some by me. This compiler, or at least the latest version of it, is currently broken, and only passes the regression tests if built with -O0.
2011-12-04Applied another patch by Zoltan to fix memory alignement issues in ecpg's sqldaMichael Meskes
code.
2011-12-03Treat ENOTDIR as ENOENT when looking for client certificate fileMagnus Hagander
This makes it possible to use a libpq app with home directory set to /dev/null, for example - treating it the same as if the file doesn't exist (which it doesn't). Per bug #6302, reported by Diego Elio Petteno
2011-11-28Add libpq connection option to disable SSL compressionMagnus Hagander
This can be used to remove the overhead of SSL compression on fast networks. Laurenz Albe
2011-11-17Applied Zoltan's patch to correctly align interval and timestamp data in ↵Michael Meskes
ecpg's sqlda.
2011-11-13Applied patch by Zoltan to fix copy&paste bug in ecpg's sqlda handling.Michael Meskes
2011-11-01Clean up whitespace and indentation in parser and scanner filesPeter Eisentraut
These are not touched by pgindent, so clean them up a bit manually.
2011-10-28De-parallelize ecpg build some more.Tom Lane
Make sure ecpg/include/ is rebuilt before the other subdirectories, so that ecpg_config.h is up to date. This is not likely to matter during production builds, only development, so no back-patch.
2011-10-18Suppress remaining -Waddress warnings from recent gcc versions.Tom Lane
Still an exercise in satisfying pedants.
2011-09-25Fully const-ify PQconnectdbParams, PQconnectStartParams, and PQpingParams.Tom Lane
The keywords and values arguments of these functions are more properly declared "const char * const *" than just "const char **". Lionel Elie Mamane, reviewed by Craig Ringer
2011-09-14Teach the makefile used to build stand-alone libpq on Windows that libpqHeikki Linnakangas
needs win32setlocale.c now. The cygwin and MSVC build scripts were changed earlier, but this was neglected. This should fix bug report #6203 by Steve.
2011-09-11Remove many -Wcast-qual warningsPeter Eisentraut
This addresses only those cases that are easy to fix by adding or moving a const qualifier or removing an unnecessary cast. There are many more complicated cases remaining.
2011-09-11Fix additional format warningPeter Eisentraut
Apparently, this only happens on 64-bit platforms.
2011-09-10Add missing format attributesPeter Eisentraut
Add __attribute__ decorations for printf format checking to the places that were missing them. Fix the resulting warnings. Add -Wmissing-format-attribute to the standard set of warnings for GCC, so these don't happen again. The warning fixes here are relatively harmless. The one serious problem discovered by this was already committed earlier in cf15fb5cabfbc71e07be23cfbc813daee6c5014f.
2011-09-08Add missing format argument to ecpg_log() callPeter Eisentraut
2011-09-07Allow bcc32 and win32 batch files to compile libpq.Bruce Momjian
Backpatch to 9.1. By Hiroshi Saito
2011-09-02Fix brace indentation of commit 63d06ef59156719efd0208c62e764a69611b3f12 to ↵Michael Meskes
fit PostgreSQL style.
2011-09-01Remove spurious comma. Spotted by Tom.Heikki Linnakangas
2011-09-01libpq compiles various pgport files like ecpg does, and needs similar MakefileHeikki Linnakangas
changes for the win32 setlocale() wrapper I put into ecpg, to make it compile on MinGW.
2011-09-01In ecpglib restore LC_NUMERIC in case of an error.Michael Meskes
2011-09-01Fix MinGW build, broken by my previous patch to add a setlocale() wrapperHeikki Linnakangas
on Windows. ecpglib doesn't link with libpgport, but picks and compiles the .c files it needs individually. To cope with that, move the setlocale() wrapper from chklocale.c to a separate setlocale.c file, and include that in ecpglib.
2011-08-27Don't assume that "E" response to NEGOTIATE_SSL_CODE means pre-7.0 server.Tom Lane
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-27Ensure we discard unread/unsent data when abandoning a connection attempt.Tom Lane
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.