summaryrefslogtreecommitdiff
path: root/contrib
Commit message (Collapse)AuthorAgeFilesLines
* Take buffer lock while inspecting btree index pages in contrib/pageinspect.Tom Lane2012-11-301-9/+11
| | | | It's not safe to examine a shared buffer without any lock.
* Prevent access to external files/URLs via contrib/xml2's xslt_process().Tom Lane2012-08-144-21/+103
| | | | | | | | | | | | | | | | | | | | | | | libxslt offers the ability to read and write both files and URLs through stylesheet commands, thus allowing unprivileged database users to both read and write data with the privileges of the database server. Disable that through proper use of libxslt's security options. Also, remove xslt_process()'s ability to fetch documents and stylesheets from external files/URLs. While this was a documented "feature", it was long regarded as a terrible idea. The fix for CVE-2012-3489 broke that capability, and rather than expend effort on trying to fix it, we're just going to summarily remove it. While the ability to write as well as read makes this security hole considerably worse than CVE-2012-3489, the problem is mitigated by the fact that xslt_process() is not available unless contrib/xml2 is installed, and the longstanding warnings about security risks from that should have discouraged prudent DBAs from installing it in security-exposed databases. Reported and fixed by Peter Eisentraut. Security: CVE-2012-3488
* Fix some more bugs in contrib/xml2's xslt_process().Tom Lane2012-06-041-0/+14
| | | | | | | | | | | | | | | It failed to check for error return from xsltApplyStylesheet(), as reported by Peter Gagarinov. (So far as I can tell, libxslt provides no convenient way to get a useful error message in failure cases. There might be some inconvenient way, but considering that this code is deprecated it's hard to get enthusiastic about putting lots of work into it. So I just made it say "failed to apply stylesheet", in line with the existing error checks.) While looking at the code I also noticed that the string returned by xsltSaveResultToString was never freed, resulting in a session-lifespan memory leak. Back-patch to all supported versions.
* Fix incorrect password transformation in contrib/pgcrypto's DES crypt().Tom Lane2012-05-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Overly tight coding caused the password transformation loop to stop examining input once it had processed a byte equal to 0x80. Thus, if the given password string contained such a byte (which is possible though not highly likely in UTF8, and perhaps also in other non-ASCII encodings), all subsequent characters would not contribute to the hash, making the password much weaker than it appears on the surface. This would only affect cases where applications used DES crypt() to encode passwords before storing them in the database. If a weak password has been created in this fashion, the hash will stop matching after this update has been applied, so it will be easy to tell if any passwords were unexpectedly weak. Changing to a different password would be a good idea in such a case. (Since DES has been considered inadequately secure for some time, changing to a different encryption algorithm can also be recommended.) This code, and the bug, are shared with at least PHP, FreeBSD, and OpenBSD. Since the other projects have already published their fixes, there is no point in trying to keep this commit private. This bug has been assigned CVE-2012-2143, and credit for its discovery goes to Rubin Xu and Joseph Bonneau.
* Fix a couple of contrib/dblink bugs.Tom Lane2012-04-031-6/+18
| | | | | | | | | | | | | | | dblink_exec leaked temporary database connections if any error occurred after connection setup, for example SELECT dblink_exec('...connect string...', 'select 1/0'); Add a PG_TRY block to ensure PQfinish gets done when it is needed. (dblink_record_internal is on the hairy edge of needing similar treatment, but seems not to be actively broken at the moment.) Also, in 9.0 and up, only one of the three functions using tuplestore return mode was properly checking that the query context would allow a tuplestore result. Noted while reviewing dblink patch. Back-patch to all supported branches.
* Fix longstanding error in contrib/intarray's int[] & int[] operator.Tom Lane2012-02-163-6/+16
| | | | | | | | | | The array intersection code would give wrong results if the first entry of the correct output array would be "1". (I think only this value could be at risk, since the previous word would always be a lower-bound entry with that fixed value.) Problem spotted by Julien Rouhaud, initial patch by Guillaume Lelarge, cosmetic improvements by me.
* Fix error detection in contrib/pgcrypto's encrypt_iv() and decrypt_iv().Tom Lane2012-01-271-4/+4
| | | | | | | | Due to oversights, the encrypt_iv() and decrypt_iv() functions failed to report certain types of invalid-input errors, and would instead return random garbage values. Marko Kreen, per report from Stefan Kaltenbrunner
* Fix one-byte buffer overrun in contrib/test_parser.Tom Lane2012-01-091-9/+10
| | | | | | | | | | The original coding examined the next character before verifying that there *is* a next character. In the worst case with the input buffer right up against the end of memory, this would result in a segfault. Problem spotted by Paul Guyot; this commit extends his patch to fix an additional case. In addition, make the code a tad more readable by not overloading the usage of *tlen.
* Fix bogus code in contrib/ tsearch dictionary examples.Tom Lane2011-11-032-4/+6
| | | | | | | | | | | | | | Both dict_int and dict_xsyn were blithely assuming that whatever memory palloc gives back will be pre-zeroed. This would typically work for just about long enough to run their regression tests, and no longer :-(. The pre-9.0 code in dict_xsyn was even lamer than that, as it would happily give back a pointer to the result of palloc(0), encouraging its caller to access off the end of memory. Again, this would just barely fail to fail as long as memory contained nothing but zeroes. Per a report from Rodrigo Hjort that code based on these examples didn't work reliably.
* Make pgstatindex respond to cancel interrupts.Robert Haas2011-10-061-0/+2
| | | | | | | | | A similar problem for pgstattuple() was fixed in April of 2010 by commit 33065ef8bc52253ae855bc959576e52d8a28ba06, but pgstatindex() seems to have been overlooked. Back-patch all the way, as with that commit, though not to 7.4 through 8.1, since those are now EOL.
* Fix pgstatindex() to give consistent results for empty indexes.Tom Lane2011-08-241-2/+10
| | | | | | | | | | | | | | | | For an empty index, the pgstatindex() function would compute 0.0/0.0 for its avg_leaf_density and leaf_fragmentation outputs. On machines that follow the IEEE float arithmetic standard with any care, that results in a NaN. However, per report from Rushabh Lathia, Microsoft couldn't manage to get this right, so you'd get a bizarre error on Windows. Fix by forcing the results to be NaN explicitly, rather than relying on the division operator to give that or the snprintf function to print it correctly. I have some doubts that this is really the most useful definition, but it seems better to remain backward-compatible with those platforms for which the behavior wasn't completely broken. Back-patch to 8.2, since the code is like that in all current releases.
* Remove excessively backpatched gitignore filesPeter Eisentraut2011-07-116-6/+0
| | | | | These caused directories from future releases to appear in the backbranch tree.
* Apply upstream fix for blowfish signed-character bug (CVE-2011-2483).Tom Lane2011-06-212-10/+17
| | | | | | | | | | | | | | | | | | | | | A password containing a character with the high bit set was misprocessed on machines where char is signed (which is most). This could cause the preceding one to three characters to fail to affect the hashed result, thus weakening the password. The result was also unportable, and failed to match some other blowfish implementations such as OpenBSD's. Since the fix changes the output for such passwords, upstream chose to provide a compatibility hack: password salts beginning with $2x$ (instead of the usual $2a$ for blowfish) are intentionally processed "wrong" to give the same hash as before. Stored password hashes can thus be modified if necessary to still match, though it'd be better to change any affected passwords. In passing, sync a couple other upstream changes that marginally improve performance and/or tighten error checking. Back-patch to all supported branches. Since this issue is already public, no reason not to commit the fix ASAP.
* Replace strdup() with pstrdup(), to avoid leaking memory.Heikki Linnakangas2011-05-181-1/+1
| | | | | It's been like this since the seg module was introduced, so backpatch to 8.2 which is the oldest supported version.
* Add missing gitignore filePeter Eisentraut2011-05-021-0/+1
|
* Prevent buffer overrun while parsing an integer in a "query_int" value.Tom Lane2011-01-271-10/+16
| | | | | | | | | | | | | | contrib/intarray's gettoken() uses a fixed-size buffer to collect an integer's digits, and did not guard against overrunning the buffer. This is at least a backend crash risk, and in principle might allow arbitrary code execution. The code didn't check for overflow of the integer value either, which while not presenting a crash risk was still bad. Thanks to Apple Inc's security team for reporting this issue and supplying the fix. Security: CVE-2010-4015
* Fix erroneous parsing of tsquery input "... & !(subexpression) | ..."Tom Lane2010-12-192-4/+4
| | | | | | | | | | | After parsing a parenthesized subexpression, we must pop all pending ANDs and NOTs off the stack, just like the case for a simple operand. Per bug #5793. Also fix clones of this routine in contrib/intarray and contrib/ltree, where input of types query_int and ltxtquery had the same problem. Back-patch to all supported versions.
* Fix contrib/seg's GiST picksplit method.Tom Lane2010-12-151-1/+1
| | | | | | | | Fix the same size_alpha versus size_beta typo that was recently fixed in contrib/cube. Noted by Alexander Korotkov. Back-patch to all supported branches (there is a more invasive fix in HEAD).
* Fix significant memory leak in contrib/xml2 functions.Tom Lane2010-11-261-72/+90
| | | | | | | | | Most of the functions that execute XPath queries leaked the data structures created by libxml2. This memory would not be recovered until end of session, so it mounts up pretty quickly in any serious use of the feature. Per report from Pavel Stehule, though this isn't his patch. Back-patch to all supported branches.
* Don't raise "identifier will be truncated" messages in dblinkItagaki Takahiro2010-11-251-2/+2
| | | | except creating new connections.
* Fix bug in cube picksplit algorithm.Robert Haas2010-11-141-1/+1
| | | | Alexander Korotkov
* If pk is NULL, the backend would segfault when accessing ->algo and theHeikki Linnakangas2010-10-201-1/+3
| | | | | | | | following NULL check was never reached. This problem was found by Coccinelle (null_ref.cocci from coccicheck). Marti Raudsepp
* Add contrib/xml2/pgxml.sql to .gitignoreRobert Haas2010-09-231-0/+1
| | | | Kevin Grittner
* Some more gitignore cleanups: cover contrib and PL regression test outputs.Tom Lane2010-09-2217-0/+35
| | | | | Also do some further work in the back branches, where quite a bit wasn't covered by Magnus' original back-patch.
* Convert cvsignore to gitignore, and add .gitignore for build targets.Magnus Hagander2010-09-2239-6/+45
|
* Deprecate the use of => as an operator name.Robert Haas2010-06-222-2/+9
| | | | | | | | | | In HEAD, emit a warning when an operator named => is defined. In both HEAD and the backbranches (except in 8.2, where contrib modules do not have documentation), document that hstore's text => text operator may be removed in a future release, and encourage the use of the hstore(text, text) function instead. This function only exists in HEAD (previously, it was called tconvert), so backpatch it back to 8.2, when hstore was added. Per discussion.
* Fix dblink_build_sql_insert() and related functions to handle droppedTom Lane2010-06-153-32/+101
| | | | | | | | columns correctly. In passing, get rid of some dead logic in the underlying get_sql_insert() etc functions --- there is no caller that will pass null value-arrays to them. Per bug report from Robert Voinea.
* Consolidate and improve checking of key-column-attnum arguments forTom Lane2010-06-152-121/+92
| | | | | | | | | | dblink_build_sql_insert() and related functions. In particular, be sure to reject references to dropped and out-of-range column numbers. The numbers are still interpreted as physical column numbers, though, for backward compatibility. This patch replaces Joe's patch of 2010-02-03, which handled only some aspects of the problem.
* Rearrange dblink's dblink_build_sql_insert() and related routines to open andTom Lane2010-06-141-128/+83
| | | | | | | | | | | lock the target relation just once per SQL function call. The original coding obtained and released lock several times per call. Aside from saving a not-insignificant number of cycles, this eliminates possible race conditions if someone tries to modify the relation's schema concurrently. Also centralize locking and permission-checking logic. Problem noted while investigating a trouble report from Robert Voinea --- his problem is still to be fixed, though.
* Fix connection leak in dblink when dblink_connect() or dblink_connect_u()Itagaki Takahiro2010-06-091-1/+6
| | | | | | end with "duplicate connection name" errors. Backported to release 7.4.
* Add missed function dblink_connect_u(text[,text]) to uninstall scriptTeodor Sigaev2010-06-071-1/+5
|
* Fix dblink to treat connection names longer than NAMEDATALEN-2 (62 bytes).Itagaki Takahiro2010-06-031-11/+11
| | | | | | | Now long names are adjusted with truncate_identifier() and NOTICE messages are raised if names are actually truncated. Backported to release 8.0.
* Fix typos in comments, spotted by Josh Kupershmidt.Heikki Linnakangas2010-05-151-4/+4
|
* Ensure that contrib/pgstattuple functions respond to cancel interruptsTom Lane2010-04-021-1/+11
| | | | | | reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops. Tatsuhito Kasahara
* Fix ginint4_queryextract() to actually do what it was intended to do for anTom Lane2010-03-251-1/+1
| | | | | | | | | unsatisfiable query, such as indexcol && empty_array. It should return -1 to tell GIN no scan is required; but silly typo disabled the logic for that, resulting in unnecessary "GIN indexes do not support whole-index scans" error. Per bug report from Jeff Trout. Back-patch to 8.3 where the logic was introduced.
* Make contrib/xml2 use core xml.c's error handler, when available (that is,Tom Lane2010-03-032-82/+17
| | | | | | | | | | | | | in versions >= 8.3). The core code is more robust and efficient than what was there before, and this also reduces risks involved in swapping different libxml error handler settings. Before 8.3, there is still some risk of problems if add-on modules such as Perl invoke libxml without setting their own error handler. Given the lack of reports I'm not sure there's a risk in practice, so I didn't take the step of actually duplicating the core code into older contrib/xml2 branches. Instead I just tweaked the existing code to ensure it didn't leave a dangling pointer to short-lived memory when throwing an error.
* Fix contrib/xml2 so regression test still works when it's built without libxslt.Tom Lane2010-03-014-14/+133
| | | | | | | This involves modifying the module to have a stable ABI, that is, the xslt_process() function still exists even without libxslt. It throws a runtime error if called, but doesn't prevent executing the CREATE FUNCTION call. This is a good thing anyway to simplify cross-version upgrades.
* Remove xmlCleanupParser calls from contrib/xml2.Tom Lane2010-03-012-33/+4
| | | | | | | These are unnecessary and probably dangerous. I don't see any immediate risk situations in the core XML support or contrib/xml2 itself, but there could be issues with external uses of libxml2, and in any case it's an accident waiting to happen.
* Back-patch today's memory management fixups in contrib/xml2.Tom Lane2010-03-015-232/+388
| | | | | | | | | | | Prior to 8.3, these changes are not critical for compatibility with core Postgres, since core had no libxml2 calls then. However there is still a risk if contrib/xml2 is used along with libxml2 functionality in Perl or other loadable modules. So back-patch to all versions. Also back-patch addition of regression tests. I'm not sure how many of the cases are interesting without the interaction with core xml code, but a silly regression test is still better than none at all.
* Allow zero-dimensional (ie, empty) arrays in contrib/ltree operations.Tom Lane2010-02-244-9/+9
| | | | | | | | | | | | | | | | The main motivation for changing this is bug #4921, in which it's pointed out that it's no longer safe to apply ltree operations to the result of ARRAY(SELECT ...) if the sub-select might return no rows. Before 8.3, the ARRAY() construct would return NULL, which might or might not be helpful but at least it wouldn't result in an error. Now it returns an empty array which results in a failure for no good reason, since the ltree operations are all perfectly capable of dealing with zero-element arrays. As far as I can find, these ltree functions are the only places where zero array dimensionality is rejected unnecessarily. Back-patch to 8.3 to prevent behavioral regression of queries that worked in older releases.
* Add a note to the documentation of pg_standby that it's important thatHeikki Linnakangas2010-02-051-1/+4
| | | | | | | | | | | | the postgres process has permissions to delete the trigger file, per suggestion by Mason Hale. Also fix pg_standby to do a more predictable exit(200) instead of the current exit(-1) when the unlink of the trigger file fails anyway. This only affects 8.3 branch. Older versions didn't have pg_standby, and in 8.4 upwards pg_standby is no longer responsible for deleting the trigger file; it's supposed to be done by recovery_end_command instead.
* Check to ensure the number of primary key fields supplied does notJoe Conway2010-02-033-1/+72
| | | | | | | exceed the total number of non-dropped source table fields for dblink_build_sql_*(). Addresses bug report from Rushabh Lathia. Backpatch all the way to the 7.3 branch.
* Oops, previous backpatch applied incorrectly.Heikki Linnakangas2009-12-291-1/+1
|
* Previous fix for temporary file management broke returning a set fromHeikki Linnakangas2009-12-292-24/+0
| | | | | | | | | | | | | | PL/pgSQL function within an exception handler. Make sure we use the right resource owner when we create the tuplestore to hold returned tuples. Simplify tuplestore API so that the caller doesn't need to be in the right memory context when calling tuplestore_put* functions. tuplestore.c automatically switches to the memory context used when the tuplestore was created. Tuplesort was already modified like this earlier. This patch also removes the now useless MemoryContextSwitch calls from callers. Report by Aleksei on pgsql-bugs on Dec 22 2009. Backpatch to 8.1, like the previous patch that broke this.
* Disable triggering failover with a signal in pg_standby on Windows, becauseHeikki Linnakangas2009-11-041-2/+8
| | | | | | | Windows doesn't do signal processing like other platforms do. It never really worked, but recent changes to the signal handling made it crash. This fixes bug #4961. Patch by Fujii Masao.
* Make sure FD_SETSIZE is set before we include any WindowsMagnus Hagander2009-07-301-3/+6
| | | | | | header files. Josh Williams
* Fix xslt_process() to ensure that it inserts a NULL terminator after theTom Lane2009-07-101-7/+11
| | | | | | | | | | | | last pair of parameter name/value strings, even when there are MAXPARAMS of them. Aboriginal bug in contrib/xml2, noted while studying bug #4912 (though I'm not sure whether there's something else involved in that report). This might be thought a security issue, since it's a potential backend crash; but considering that untrustworthy users shouldn't be allowed to get their hands on xslt_process() anyway, it's probably not worth getting excited about.
* Remove beer-ware license from crypt-md5.c, perMagnus Hagander2009-04-151-7/+2
| | | | | | | approval from Poul-Henning Kamp. This makes the file the same standard 2-clause BSD as the rest of PostgreSQL.
* Fix contrib/pg_freespacemap's underestimate of the number of pages itTom Lane2009-04-071-2/+6
| | | | | | could find in the FSM. Per report from Dimitri Fontaine and Andrew Gierth. (Affects only 8.2 and 8.3 since HEAD no longer has MaxFSMPages at all.)
* Defend against non-ASCII letters in fuzzystrmatch code. The functionsTom Lane2009-04-071-11/+29
| | | | | still don't behave very sanely for multibyte encodings, but at least they won't be indexing off the ends of static arrays.