summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2006-05-21Modify libpq's string-escaping routines to be aware of encoding considerationsTom Lane
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-21Add a new GUC parameter backslash_quote, which determines whether the SQLTom Lane
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-21Change the backend to reject strings containing invalidly-encoded multibyteTom Lane
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-21Change \' to '', for SQL standards compliance. Backpatch to 7.3, 7.4,Bruce Momjian
and 8.0. Later releases already patched.
2006-05-12Fix the sense of the test on DH_check()'s return value. This was preventingTom Lane
custom-generated DH parameters from actually being used by the server. Found by Michael Fuhr.
2006-05-11Remove unnecessary .seg/.section directives, per Alan Stange.Tom Lane
2006-04-19Fix ancient memory leak in PQprintTuples(); our code no longer uses thisTom Lane
routine, but perhaps some applications do. Found by Martijn van Oosterhout using Coverity.
2006-03-04Minor teak.Tatsuo Ishii
2006-03-04Tighten up SJIS byte sequence check. Now we reject invalid SJIS byteTatsuo Ishii
sequence such as "0x95 0x27". Patches from Akio Ishida.
2006-02-20Fix three Python reference leaks in PLy_traceback(). This would resultNeil Conway
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-12Fix bug in SET SESSION AUTHORIZATION that allows unprivileged users to crashTom Lane
the server, if it has been compiled with Asserts enabled (CVE-2006-0553). Thanks to Akio Ishida for reporting this problem.
2006-02-12Stamp releases for 2006-02-14 releaseBruce Momjian
2006-01-21Repair longstanding bug in slru/clog logic: it is possible for two backendsTom Lane
to try to create a log segment file concurrently, but the code erroneously specified O_EXCL to open(), resulting in a needless failure. Before 7.4, it was even a PANIC condition :-(. Correct code is actually simpler than what we had, because we can just say O_CREAT to start with and not need a second open() call. I believe this accounts for several recent reports of hard-to-reproduce "could not create file ...: File exists" errors in both pg_clog and pg_subtrans.
2006-01-12Repair "Halloween problem" in EvalPlanQual: a tuple that's been inserted byTom Lane
our own command (or more generally, xmin = our xact and cmin >= current command ID) should not be seen as good. Else we may try to update rows we already updated. This error was inserted last August while fixing the even bigger problem that the old coding wouldn't see *any* tuples inserted by our own transaction as good. Per report from Euler Taveira de Oliveira.
2006-01-09Fix pg_dump to add the required OPERATOR() decoration to schema-qualifiedTom Lane
operator names. This is needed when dumping operator definitions that have COMMUTATOR (or similar) links to operators in other schemas. Apparently Daniel Whitter is the first person ever to try this :-(
2006-01-06Fix failure to apply domain constraints to a NULL constant that's added toTom Lane
an INSERT target list during rule rewriting. Per report from John Supplee.
2006-01-05Stamp release 7.3.13.Bruce Momjian
2006-01-05Arrange to set the LC_XXX environment variables to match our locale setup.Tom Lane
Back-patch of previous fix in HEAD for plperl-vs-locale issue.
2006-01-05Add port support for unsetenv() in back branches. Needed for localeTom Lane
environment fix.
2005-12-24Fix long standing Asian multibyte charsets bug.Tatsuo Ishii
See: Subject: [HACKERS] bugs with certain Asian multibyte charsets From: Tatsuo Ishii <ishii@sraoss.co.jp> To: pgsql-hackers@postgresql.org Date: Sat, 24 Dec 2005 18:25:33 +0900 (JST) for more details.
2005-12-22Adjust string comparison so that only bitwise-equal strings are consideredTom Lane
equal: if strcoll claims two strings are equal, check it with strcmp, and sort according to strcmp if not identical. This fixes inconsistent behavior under glibc's hu_HU locale, and probably under some other locales as well. Also, take advantage of the now-well-defined behavior to speed up texteq, textne, bpchareq, bpcharne: they may as well just do a bitwise comparison and not bother with strcoll at all. NOTE: affected databases may need to REINDEX indexes on text columns to be sure they are self-consistent.
2005-12-15Back-patch 7.4 change to show that freebsd 5 and up don't needTom Lane
float8-small-is-zero. Per Mark Kirkwood.
2005-12-13Remove unused HAVE_STRUCT_SOCKCRED code, which was causing a duplicate-Tom Lane
variable-definition error on recent FreeBSDen (evidently, that platform also HAS_STRUCT_CMSGCRED). Backport of 7.4 fix dated 2003-10-25.
2005-12-09Stamp 7.3.12.REL7_3_12Tom Lane
2005-12-05Add regression test to see if the min/max values of int8 convert correctly.Tom Lane
2005-11-03Fix longstanding race condition in transaction log management: there was aTom Lane
very narrow window in which SimpleLruReadPage or SimpleLruWritePage could think that I/O was needed when it wasn't (and indeed the buffer had already been assigned to another page). This would result in an Assert failure if Asserts were enabled, and probably in silent data corruption if not. Reported independently by Jim Nasby and Robert Creager. I intend a more extensive fix when 8.2 development starts, but this is a reasonably low-impact patch for the existing branches.
2005-10-25Fix longstanding bug that would sometimes let the planner generate a bad planTom Lane
for an outer join; symptom is bogus error "RIGHT JOIN is only supported with merge-joinable join conditions". Problem was that select_mergejoin_clauses did its tests in the wrong order. We need to force left join not right join for a merge join when there are non-mergeable join clauses; but the test for this only accounted for mergejoinability of the clause operator, and not whether the left and right Vars were of the proper relations. Per report from Jean-Pierre Pelletier.
2005-10-14Pass a strdup'd ident string to openlog(), to ensure that reallocationTom Lane
of GUC memory doesn't cause us to start emitting a bogus ident string. Per report from Han Holl. Also some trivial code cleanup in write_syslog.
2005-10-12Fix longstanding bug found by Atsushi Ogawa: _bt_check_unique would markTom Lane
the wrong buffer dirty when trying to kill a dead index entry that's on a page after the one it started on. No risk of data corruption, just inefficiency, but still a bug.
2005-10-03Stamp release 7.3.11.REL7_3_11Tom Lane
2005-08-30Fix missing rows in queryTeodor Sigaev
update a=.. where a... with GiST index on column 'a' Backpatch from 8.0 branch
2005-08-26Back-patch fixes for problems with VACUUM destroying t_ctid chains too soon,Tom Lane
and with insufficient paranoia in code that follows t_ctid links. This patch covers the 7.3 branch.
2005-08-16Reject operator names >= NAMEDATALEN characters. These will not workTom Lane
anyway, and in assert-enabled builds you are likely to get an assertion failure. Backpatch as far as 7.3; 7.2 seems not to have the problem.
2005-07-18Fix bogus backslash sequences, per Kris Jurka.Tom Lane
2005-07-18MemSet() must not cast its pointer argument to int32* until after it hasTom Lane
checked that the pointer is actually word-aligned. Casting a non-aligned pointer to int32* is technically illegal per the C spec, and some recent versions of gcc actually generate bad code for the memset() when given such a pointer. Per report from Andrew Morrow.
2005-07-17Adjust alter_table regression test to avoid conflicts with rangefuncsTom Lane
and prepare tests, which cause intermittent failures in parallel test mode. Back-port of fix originally applied to 8.0 and 7.4 branches; the problems do not appear to exist in 7.2 branch but they do occur in 7.3. Per buildfarm results.
2005-07-16Mark the geometry regression test as an ignorable failure in the pre-7.4Tom Lane
branches. Per discussion, this seems saner than trying to maintain last-significant-digit regression test outputs for all supported platforms.
2005-07-14Fix mis-backport of libpq memory leak fix. Per Michael Fuhr.Tom Lane
2005-07-13Fix libpq memory leak during PQreset() --- closePGconn() was notTom Lane
freeing all transient state of the PGconn object.
2005-07-08Make libpq_gettext save and restore errno in a Windows-compatible way.Tom Lane
Also, back-patch fix into back branches.
2005-06-25Fix ancient memory leak in index_create(): RelationInitIndexAccessInfoTom Lane
was being called twice in normal operation, leading to a leak of one set of relcache subsidiary info. Per report from Jeff Gold.
2005-06-20plpgsql's exec_assign_value() freed the old value of a variable beforeTom Lane
copying/converting the new value, which meant that it failed badly on "var := var" if var is of pass-by-reference type. Fix this and a similar hazard in exec_move_row(); not sure that the latter can manifest before 8.0, but patch it all the way back anyway. Per report from Dave Chapeskie.
2005-06-14The random selection in function linear() could deliver a value equal to maxTom Lane
if geqo_rand() returns exactly 1.0, resulting in failure due to indexing off the end of the pool array. Also, since this is using inexact float math, it seems wise to guard against roundoff error producing values slightly outside the expected range. Per report from bug@zedware.org.
2005-06-11Fix bug in MIC -> EUC_JP conversion. Per Atsushi Ogawa.Tatsuo Ishii
2005-06-05Code for SET/SHOW TIME ZONE with a fixed-interval timezone was notTom Lane
prepared for HAVE_INT64_TIMESTAMP. Per report from Guillaume Beaudoin.
2005-06-02Push enable/disable of notify and catchup interrupts all the way downTom Lane
to just around the bare recv() call that gets a command from the client. The former placement in PostgresMain was unsafe because the intermediate processing layers (especially SSL) use facilities such as malloc that are not necessarily re-entrant. Per report from counterstorm.com.
2005-05-31Add test to WAL replay to verify that xl_prev points back to the previousTom Lane
WAL record; this is necessary to be sure we recognize stale WAL records when a WAL page was only partially written during a system crash.
2005-05-29expandRTE and get_rte_attribute_type mistakenly always imputed typmod -1Tom Lane
to columns of an RTE that was a function returning RECORD with a column definition list. Apparently no one has tried to use non-default typmod with a function returning RECORD before.
2005-05-25Fix previous patch to exprTypmod.Tatsuo Ishii
2005-05-24Inserting 5 characters into char(10) does not produce 5 padding spacesTatsuo Ishii
if they are two-byte multibyte characters. Same thing can be happen if octet_length(multibyte_chars) == n where n is char(n). Long standing bug since 7.3 days. Per report and fix from Yoshiyuki Asaba.