Skip to content
Snippets Groups Projects
  1. Aug 30, 2012
    • Alvaro Herrera's avatar
      Split tuple struct defs from htup.h to htup_details.h · c219d9b0
      Alvaro Herrera authored
      This reduces unnecessary exposure of other headers through htup.h, which
      is very widely included by many files.
      
      I have chosen to move the function prototypes to the new file as well,
      because that means htup.h no longer needs to include tupdesc.h.  In
      itself this doesn't have much effect in indirect inclusion of tupdesc.h
      throughout the tree, because it's also required by execnodes.h; but it's
      something to explore in the future, and it seemed best to do the htup.h
      change now while I'm busy with it.
      c219d9b0
  2. Aug 15, 2012
    • Tom Lane's avatar
      Prevent access to external files/URLs via contrib/xml2's xslt_process(). · adc97d03
      Tom Lane authored
      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
      adc97d03
  3. Jun 10, 2012
  4. Jun 05, 2012
    • Tom Lane's avatar
      Fix some more bugs in contrib/xml2's xslt_process(). · d9b31e48
      Tom Lane authored
      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.
      d9b31e48
  5. Oct 12, 2011
    • Tom Lane's avatar
      Throw a useful error message if an extension script file is fed to psql. · 458857cc
      Tom Lane authored
      We have seen one too many reports of people trying to use 9.1 extension
      files in the old-fashioned way of sourcing them in psql.  Not only does
      that usually not work (due to failure to substitute for MODULE_PATHNAME
      and/or @extschema@), but if it did work they'd get a collection of loose
      objects not an extension.  To prevent this, insert an \echo ... \quit
      line that prints a suitable error message into each extension script file,
      and teach commands/extension.c to ignore lines starting with \echo.
      That should not only prevent any adverse consequences of loading a script
      file the wrong way, but make it crystal clear to users that they need to
      do it differently now.
      
      Tom Lane, following an idea of Andrew Dunstan's.  Back-patch into 9.1
      ... there is not going to be much value in this if we wait till 9.2.
      458857cc
  6. Aug 19, 2011
    • Robert Haas's avatar
      Fix contrib/sepgsql and contrib/xml2 to always link required libraries. · 10c378f2
      Robert Haas authored
      contrib/xml2 can get by without libxslt; the relevant features just
      won't work.  But if doesn't have libxml2, or if sepgsql doesn't have
      libselinux, the link succeeds but the module then fails to work at load
      time.  To avoid that, link the require libraries unconditionally, so
      that it will be clear at link-time that there is a problem.
      
      Per discussion with Tom Lane and KaiGai Kohei.
      10c378f2
  7. Jul 20, 2011
    • Tom Lane's avatar
      Rewrite libxml error handling to be more robust. · cacd42d6
      Tom Lane authored
      libxml reports some errors (like invalid xmlns attributes) via the error
      handler hook, but still returns a success indicator to the library caller.
      This causes us to miss some errors that are important to report.  Since the
      "generic" error handler hook doesn't know whether the message it's getting
      is for an error, warning, or notice, stop using that and instead start
      using the "structured" error handler hook, which gets enough information
      to be useful.
      
      While at it, arrange to save and restore the error handler hook setting in
      each libxml-using function, rather than assuming we can set and forget the
      hook.  This should improve the odds of working nicely with third-party
      libraries that also use libxml.
      
      In passing, volatile-ize some local variables that get modified within
      PG_TRY blocks.  I noticed this while testing with an older gcc version
      than I'd previously tried to compile xml.c with.
      
      Florian Pflug and Tom Lane, with extensive review/testing by Noah Misch
      cacd42d6
  8. Apr 25, 2011
    • Peter Eisentraut's avatar
      Support "make check" in contrib · f8ebe3bc
      Peter Eisentraut authored
      Added a new option --extra-install to pg_regress to arrange installing
      the respective contrib directory into the temporary installation.
      This is currently not yet supported for Windows MSVC builds.
      
      Updated the .gitignore files for contrib modules to ignore the
      leftovers of a temp-install check run.
      
      Changed the exit status of "make check" in a pgxs build (which still
      does nothing) to 0 from 1.
      
      Added "make check" in contrib to top-level "make check-world".
      f8ebe3bc
  9. Apr 10, 2011
  10. Feb 18, 2011
  11. Feb 14, 2011
    • Tom Lane's avatar
      de06cfe8
    • Tom Lane's avatar
      Avoid use of CREATE OR REPLACE FUNCTION in extension installation files. · 029fac22
      Tom Lane authored
      It was never terribly consistent to use OR REPLACE (because of the lack of
      comparable functionality for data types, operators, etc), and
      experimentation shows that it's now positively pernicious in the extension
      world.  We really want a failure to occur if there are any conflicts, else
      it's unclear what the extension-ownership state of the conflicted object
      ought to be.  Most of the time, CREATE EXTENSION will fail anyway because
      of conflicts on other object types, but an extension defining only
      functions can succeed, with bad results.
      029fac22
    • Tom Lane's avatar
      Convert contrib modules to use the extension facility. · 629b3af2
      Tom Lane authored
      This isn't fully tested as yet, in particular I'm not sure that the
      "foo--unpackaged--1.0.sql" scripts are OK.  But it's time to get some
      buildfarm cycles on it.
      
      sepgsql is not converted to an extension, mainly because it seems to
      require a very nonstandard installation process.
      
      Dimitri Fontaine and Tom Lane
      629b3af2
  12. Nov 26, 2010
    • Tom Lane's avatar
      Fix significant memory leak in contrib/xml2 functions. · 4a2516a7
      Tom Lane authored
      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.
      4a2516a7
  13. Nov 23, 2010
  14. Sep 24, 2010
  15. Sep 22, 2010
  16. Sep 20, 2010
  17. Aug 13, 2010
  18. Aug 11, 2010
  19. Jul 06, 2010
  20. Mar 03, 2010
    • Tom Lane's avatar
      Make contrib/xml2 use core xml.c's error handler, when available (that is, · 5e47403b
      Tom Lane authored
      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.
      5e47403b
  21. Mar 01, 2010
    • Tom Lane's avatar
      Fix contrib/xml2 so regression test still works when it's built without libxslt. · d6a6f8c6
      Tom Lane authored
      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.
      d6a6f8c6
    • Tom Lane's avatar
      Remove xmlCleanupParser calls from contrib/xml2. · a1020909
      Tom Lane authored
      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.
      a1020909
  22. Feb 28, 2010
    • Tom Lane's avatar
      Fix up memory management problems in contrib/xml2. · 936c4af1
      Tom Lane authored
      Get rid of the code that attempted to funnel libxml2's memory allocations
      into palloc.   We already knew from experience with the core xml datatype
      that trying to do this is simply not reliable.  Unlike the core code, I
      did not bother adding a lot of PG_TRY/PG_CATCH logic to try to ensure that
      everything is cleaned up on error exit.  Hence, we might leak some memory
      if one of these functions fails partway through.  Given the deprecated
      status of this contrib module and the fact that errors partway through
      the functions shouldn't be too common, it doesn't seem worth worrying about.
      
      Also fix a separate bug in xpath_table, that it did the wrong things
      if given a result tuple descriptor with less than 2 columns.  While
      such a case isn't very useful in practice, we shouldn't fail or stomp
      memory when it occurs.
      
      Add some simple regression tests based on all the reported crash cases
      that I have on hand.
      
      This should be back-patched, but let's see if the buildfarm likes it first.
      936c4af1
    • Tom Lane's avatar
      Assorted code cleanup for contrib/xml2. No change in functionality, · a12333ee
      Tom Lane authored
      just make it a bit less ugly in places.
      a12333ee
  23. Jan 17, 2010
  24. Dec 29, 2009
    • Heikki Linnakangas's avatar
      Previous fix for temporary file management broke returning a set from · 84d723b6
      Heikki Linnakangas authored
      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.
      84d723b6
  25. Jul 10, 2009
    • Tom Lane's avatar
      Fix xslt_process() to ensure that it inserts a NULL terminator after the · e7370bab
      Tom Lane authored
      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.
      e7370bab
  26. Jun 11, 2009
  27. Jan 07, 2009
  28. Oct 29, 2008
    • Tom Lane's avatar
      Be more tense about not creating tuplestores with randomAccess = true unless · 05bba3d1
      Tom Lane authored
      backwards scan could actually happen.  In particular, pass a flag to
      materialize-mode SRFs that tells them whether they need to require random
      access.  In passing, also suppress unneeded backward-scan overhead for a
      Portal's holdStore tuplestore.  Per my proposal about reducing I/O costs for
      tuplestores.
      05bba3d1
  29. May 17, 2008
    • Andrew Dunstan's avatar
      Add $PostgreSQL$ markers to a lot of files that were missing them. · 53972b46
      Andrew Dunstan authored
      This particular batch was just for *.c and *.h file.
      
      The changes were made with the following 2 commands:
      
      find . \( \( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \) -prune \) -o  \( -name '*.[ch]'  \) \( -exec grep -q '\$PostgreSQL' {} \; -o -print \) | while read file ; do head -n 1 < $file | grep -q '^/\*' && echo $file; done | xargs -l sed -i -e '1s/^\// /' -e '1i/*\n * $PostgreSQL:$ \n *'
      
      find . \( \( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \) -prune \) -o  \( -name '*.[ch]'  \) \( -exec grep -q '\$PostgreSQL' {} \; -o -print \) | xargs -l sed -i -e '1i/*\n * $PostgreSQL:$ \n */'
      53972b46
  30. May 08, 2008
  31. May 04, 2008
  32. Mar 26, 2008
  33. Mar 25, 2008
    • Tom Lane's avatar
      Simplify and standardize conversions between TEXT datums and ordinary C · 220db7cc
      Tom Lane authored
      strings.  This patch introduces four support functions cstring_to_text,
      cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and
      two macros CStringGetTextDatum and TextDatumGetCString.  A number of
      existing macros that provided variants on these themes were removed.
      
      Most of the places that need to make such conversions now require just one
      function or macro call, in place of the multiple notational layers that used
      to be needed.  There are no longer any direct calls of textout or textin,
      and we got most of the places that were using handmade conversions via
      memcpy (there may be a few still lurking, though).
      
      This commit doesn't make any serious effort to eliminate transient memory
      leaks caused by detoasting toasted text objects before they reach
      text_to_cstring.  We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few
      places where it was easy, but much more could be done.
      
      Brendan Jurd and Tom Lane
      220db7cc
  34. Nov 13, 2007
  35. Nov 11, 2007
Loading