Commit Graph

343 Commits

Author SHA1 Message Date
Peter Eisentraut 4ab8fcba8a StrNCpy -> strlcpy (not complete) 2007-02-10 14:58:55 +00:00
Peter Eisentraut 086c189456 Normalize fgets() calls to use sizeof() for calculating the buffer size
where possible, and fix some sites that apparently thought that fgets()
will overwrite the buffer by one byte.

Also add some strlcpy() to eliminate some weird memory handling.
2007-02-08 11:10:27 +00:00
Bruce Momjian 29dccf5fe0 Update CVS HEAD for 2007 copyright. Back branches are typically not
back-stamped for this.
2007-01-05 22:20:05 +00:00
Andrew Dunstan 5133dd786b Interpret a dbName param to PQsetdbLogin as a conninfo string if it contains an = sign. Tom Lane and Andrew Dunstan. 2006-12-19 01:53:36 +00:00
Tom Lane bcd713a618 If SSL negotiation fails and SSLMODE is 'prefer', then retry without SSL.
Negotiation failure is only likely to happen if one side or the other is
misconfigured, eg. bad client certificate.  I'm not 100% convinced that
a retry is really the best thing, hence not back-patching this fix for now.
Per gripe from Sergio Cinos.
2006-11-21 16:28:00 +00:00
Peter Eisentraut b9b4f10b5b Message style improvements 2006-10-06 17:14:01 +00:00
Bruce Momjian f99a569a2e pgindent run for 8.2. 2006-10-04 00:30:14 +00:00
Tom Lane 9ba4065312 Remove separate strdup.h header file; it's redundant with port.h. 2006-09-27 15:41:24 +00:00
Tom Lane a22de540cf Fix some uses of str[n]casecmp that should be pg_str[n]casecmp,
per Magnus.
2006-09-15 21:34:23 +00:00
Bruce Momjian 43c79378c8 Allow LDAP lookups from pg_service.conf.
Albe Laurenz
2006-07-27 13:20:24 +00:00
Bruce Momjian 399a36a75d Prepare code to be built by MSVC:
o  remove many WIN32_CLIENT_ONLY defines
	o  add WIN32_ONLY_COMPILER define
	o  add 3rd argument to open() for portability
	o  add include/port/win32_msvc directory for
	   system includes

Magnus Hagander
2006-06-07 22:24:46 +00:00
Tom Lane 515112f9d4 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:19:23 +00:00
Alvaro Herrera 4adab7eed3 Fix typo in comment. 2006-05-19 14:26:58 +00:00
Bruce Momjian d0f9ca34bd Remove canonicalize_path() call for .pgpass socket directory comparison;
not worth adding path.c to libpq.
2006-05-18 16:26:44 +00:00
Bruce Momjian 18627c5531 Allow the .pgpass hostname to match the default socket directory, as
well as a blank pghost.
2006-05-17 21:50:54 +00:00
Tom Lane 20ab467d76 Improve parser so that we can show an error cursor position for errors
during parse analysis, not only errors detected in the flex/bison stages.
This is per my earlier proposal.  This commit includes all the basic
infrastructure, but locations are only tracked and reported for errors
involving column references, function calls, and operators.  More could
be done later but this seems like a good set to start with.  I've also
moved the ReportSyntaxErrorPosition logic out of psql and into libpq,
which should make it available to more people --- even within psql this
is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.
2006-03-14 22:48:25 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Tom Lane 2fc80b9ae6 Add positive defense against trying to connect when the connection
option state hasn't been fully set up.  This is possible via PQreset()
and might occur in other code paths too, so a state flag seems the
most robust solution.  Per report from Arturs Zoldners.
2006-02-13 22:33:57 +00:00
Neil Conway fb627b76cc Cosmetic code cleanup: fix a bunch of places that used "return (expr);"
rather than "return expr;" -- the latter style is used in most of the
tree. I kept the parentheses when they were necessary or useful because
the return expression was complex.
2006-01-11 08:43:13 +00:00
Bruce Momjian 436a2956d8 Re-run pgindent, fixing a problem where comment lines after a blank
comment line where output as too long, and update typedefs for /lib
directory.  Also fix case where identifiers were used as variable names
in the backend, but as typedefs in ecpg (favor the backend for
indenting).

Backpatch to 8.1.X.
2005-11-22 18:17:34 +00:00
Tom Lane d330f1554d Clean up libpq's pollution of application namespace by renaming the
exported routines of ip.c, md5.c, and fe-auth.c to begin with 'pg_'.
Also get rid of the vestigial fe_setauthsvc/fe_getauthsvc routines
altogether.
2005-10-17 16:24:20 +00:00
Bruce Momjian 1dc3498251 Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Peter Eisentraut 7fe1f9a2c2 Don't need gettext calls around debug messages. 2005-09-26 17:49:09 +00:00
Bruce Momjian 43bf3a6bc6 The attached patch updates the thread test program to run stand-alone on
Windows. The test itself is bypassed in configure as discussed, and
libpq has been updated appropriately to allow it to build in thread-safe
mode.

Dave Page
2005-08-23 21:02:05 +00:00
Bruce Momjian a970a8cb95 Back out incorrect commit. 2005-08-23 20:48:47 +00:00
Bruce Momjian eef7e30cc1 Fix function name. 2005-08-23 20:45:11 +00:00
Tom Lane 8e9c52e427 EINTR return from connect() should be treated exactly the same as
EINPROGRESS, according to Florian Hars.  I'm not completely convinced
but the spec does seem to read that way.
2005-08-11 22:53:41 +00:00
Bruce Momjian d359facb05 Remove unintended file change. 2005-08-09 05:14:26 +00:00
Bruce Momjian 487b757b7a Clarify wal_sync_method options in documentation. 2005-08-09 04:50:44 +00:00
Tom Lane faea3db958 Fix libpq memory leak during PQreset() --- closePGconn() was not
freeing all transient state of the PGconn object.
2005-07-13 15:25:55 +00:00
Neil Conway a159ad3048 Remove support for Kerberos V4. It seems no one is using this, it has
some security issues, and upstream has declared it "dead". Patch from
Magnus Hagander, minor editorialization from Neil Conway.
2005-06-27 02:04:26 +00:00
Bruce Momjian 624789d191 Cleanup for Win32 compile.
Andreas Pflug
2005-06-19 13:10:56 +00:00
Neil Conway 294505e2b1 This patch removes some old code from libpq that implements a URI-like
syntax for database connection parameters. It has been inside an
#ifdef NOT_USED block since 2001 or so and is marked as "broken", so
I don't think it is likely to be rehabilitated any time soon.
2005-06-12 00:07:07 +00:00
Neil Conway 72a5db15d1 libpq was not consistently checking for memory allocation failures. This
patch adds missing checks to the call sites of malloc(), strdup(),
PQmakeEmptyPGresult(), pqResultAlloc(), and pqResultStrdup(), and updates
the documentation. Per original report from Volkan Yazici about
PQmakeEmptyPGresult() not checking for malloc() failure.
2005-06-12 00:00:21 +00:00
Bruce Momjian c1e4869467 Remove unneeded variable test, per Tom. 2005-06-10 04:01:36 +00:00
Bruce Momjian 453d74b99c Add the "PGPASSFILE" environment variable to specify to the password
file.

Andrew Dunstan
2005-06-10 03:02:30 +00:00
Bruce Momjian 72c53ac3a7 Allow kerberos name and username case sensitivity to be specified from
postgresql.conf.

---------------------------------------------------------------------------


Here's an updated version of the patch, with the following changes:

1) No longer uses "service name" as "application version". It's instead
hardcoded as "postgres". It could be argued that this part should be
backpatched to 8.0, but it doesn't make a big difference until you can
start changing it with GUC / connection parameters. This change only
affects kerberos 5, not 4.

2) Now downcases kerberos usernames when the client is running on win32.

3) Adds guc option for "krb_caseins_users" to make the server ignore
case mismatch which is required by some KDCs such as Active Directory.
Off by default, per discussion with Tom. This change only affects
kerberos 5, not 4.

4) Updated so it doesn't conflict with the rendevouz/bonjour patch
already in ;-)

Magnus Hagander
2005-06-04 20:42:43 +00:00
Bruce Momjian bd9b2fa84b Add comments on WSAStartup usage. 2005-05-05 16:40:42 +00:00
Bruce Momjian 3731a400b4 Add WSACleanup() for Win32 socket cleanup.
Jason Erickson
2005-05-05 16:36:12 +00:00
Tom Lane e6befdc9d1 Kerberos fixes from Magnus Hagander --- in theory Kerberos 5 auth
should work on Windows now.  Also, rename set_noblock to pg_set_noblock;
since it is included in libpq, the former name polluted application
namespace.
2005-03-25 00:34:31 +00:00
Bruce Momjian 0542b1e2fe Use _() macro consistently rather than gettext(). Add translation
macros around strings that were missing them.
2005-02-22 04:43:23 +00:00
Tom Lane 889f038129 Use SHGetFolderPath instead of SHGetSpecialFolderPath to find the
APPDATA directory on Windows.  Magnus Hagander
2005-01-26 19:24:03 +00:00
Bruce Momjian 29e58330a6 Change Win32 client configuration files from *.txt to *.conf. 2005-01-14 00:25:56 +00:00
Tom Lane 8e4f4078d8 Un-break MSVC build, per Andrew Dunstan. 2005-01-10 00:19:51 +00:00
Tom Lane bbeeea1437 Minor mop-up for Windows home-directory stuff, per Magnus. 2005-01-06 21:41:45 +00:00
Tom Lane 4717992b4e Instead of a bare recv() to read the server's response to an SSL
request packet, use pqReadData().  This has the same effect since
conn->ssl isn't set yet and we aren't expecting more than one byte.
The advantage is that we will correctly detect loss-of-connection
instead of going into an infinite loop.  Per report from Hannu Krosing.
2005-01-06 20:06:58 +00:00
Tom Lane a3f98d5795 Adjust lookup of client-side profile files (.pgpass and so on) as per
discussion on pgsql-hackers-win32 list.  Documentation still needs to
be tweaked --- I'm not sure how to refer to the APPDATA folder in
user documentation.
2005-01-06 18:29:11 +00:00
Tom Lane d97ae8230e Make the various places that determine the user's "home directory"
consistent.  On Unix we now always consult getpwuid(); $HOME isn't used
at all.  On Windows the code currently consults $USERPROFILE, or $HOME
if that's not defined, but I expect this will change as soon as the win32
hackers come to a consensus.  Nothing done yet about changing the file
names used underneath $USERPROFILE.
2005-01-06 01:00:12 +00:00
Tom Lane edf3832b5c Clean up code in libpq that obtains user's home directory: make a single
subroutine that can hide platform dependencies.  The WIN32 path is still
a stub, but I await a fix from one of the win32 hackers.
Also clean up unnecessary #ifdef WIN32 ugliness in a couple of places.
2005-01-04 23:18:25 +00:00
PostgreSQL Daemon 2ff501590b Tag appropriate files for rc3
Also performed an initial run through of upgrading our Copyright date to
extend to 2005 ... first run here was very simple ... change everything
where: grep 1996-2004 && the word 'Copyright' ... scanned through the
generated list with 'less' first, and after, to make sure that I only
picked up the right entries ...
2004-12-31 22:04:05 +00:00