Skip to content
Snippets Groups Projects
  1. Aug 17, 2012
    • Tom Lane's avatar
      Check LIBXML_VERSION instead of testing in configure script. · 33f40976
      Tom Lane authored
      We had put a test for libxml2's xmlStructuredErrorContext variable in
      configure, but of course that doesn't work on Windows builds.  The next
      best alternative seems to be to test the LIBXML_VERSION symbol provided
      by xmlversion.h.
      
      Per report from Talha Bin Rizwan, though this fixes it in a different way
      than his proposed patch.
      33f40976
  2. Aug 15, 2012
    • Tom Lane's avatar
      Prevent access to external files/URLs via XML entity references. · aa2bc1f2
      Tom Lane authored
      xml_parse() would attempt to fetch external files or URLs as needed to
      resolve DTD and entity references in an XML value, thus allowing
      unprivileged database users to attempt to fetch data with the privileges
      of the database server.  While the external data wouldn't get returned
      directly to the user, portions of it could be exposed in error messages
      if the data didn't parse as valid XML; and in any case the mere ability
      to check existence of a file might be useful to an attacker.
      
      The ideal solution to this would still allow fetching of references that
      are listed in the host system's XML catalogs, so that documents can be
      validated according to installed DTDs.  However, doing that with the
      available libxml2 APIs appears complex and error-prone, so we're not going
      to risk it in a security patch that necessarily hasn't gotten wide review.
      So this patch merely shuts off all access, causing any external fetch to
      silently expand to an empty string.  A future patch may improve this.
      
      In HEAD and 9.2, also suppress warnings about undefined entities, which
      would otherwise occur as a result of not loading referenced DTDs.  Previous
      branches don't show such warnings anyway, due to different error handling
      arrangements.
      
      Credit to Noah Misch for first reporting the problem, and for much work
      towards a solution, though this simplistic approach was not his preference.
      Also thanks to Daniel Veillard for consultation.
      
      Security: CVE-2012-3489
      aa2bc1f2
  3. Aug 07, 2012
  4. Aug 06, 2012
  5. Aug 03, 2012
    • Tom Lane's avatar
      Fix bugs with parsing signed hh:mm and hh:mm:ss fields in interval input. · 225fe68c
      Tom Lane authored
      DecodeInterval() failed to honor the "range" parameter (the special SQL
      syntax for indicating which fields appear in the literal string) if the
      time was signed.  This seems inappropriate, so make it work like the
      not-signed case.  The inconsistency was introduced in my commit
      f867339c, which as noted in its log message
      was only really focused on making SQL-compliant literals work per spec.
      Including a sign here is not per spec, but if we're going to allow it
      then it's reasonable to expect it to work like the not-signed case.
      
      Also, remove bogus setting of tmask, which caused subsequent processing to
      think that what had been given was a timezone and not an hh:mm(:ss) field,
      thus confusing checks for redundant fields.  This seems to be an aboriginal
      mistake in Lockhart's commit 2cf16424.
      
      Add regression test cases to illustrate the changed behaviors.
      
      Back-patch as far as 8.4, where support for spec-compliant interval
      literals was added.
      
      Range problem reported and diagnosed by Amit Kapila, tmask problem by me.
      225fe68c
  6. Jul 24, 2012
    • Alvaro Herrera's avatar
      Change syntax of new CHECK NO INHERIT constraints · 68043258
      Alvaro Herrera authored
      The initially implemented syntax, "CHECK NO INHERIT (expr)" was not
      deemed very good, so switch to "CHECK (expr) NO INHERIT" instead.  This
      way it looks similar to SQL-standards compliant constraint attribute.
      
      Backport to 9.2 where the new syntax and feature was introduced.
      
      Per discussion.
      68043258
  7. Jul 18, 2012
    • Heikki Linnakangas's avatar
      Refactor the way code is shared between some range type functions. · 79c49131
      Heikki Linnakangas authored
      Functions like range_eq, range_before etc. are exposed at the SQL-level, but
      they're also used internally by the GiST consistent support function. The
      code sharing was done by a hack, TrickFunctionCall2, which relied on the
      knowledge that all the functions used fn_extra the same way. This commit
      splits the functions into internal versions that take a TypeCacheEntry as
      argument, and thin wrappers to expose the functions at the SQL-level. The
      internal versions can then be called directly and in a less hacky way from
      the GiST consistent function.
      
      This is just cosmetic, but backpatch to 9.2 anyway, to avoid having a
      different version of this code in the 9.2 branch. That would make
      backpatching fixes in this area more difficult.
      
      Alexander Korotkov
      79c49131
  8. Jul 15, 2012
    • Tom Lane's avatar
      Prevent corner-case core dump in rfree(). · 1116c9d1
      Tom Lane authored
      rfree() failed to cope with the case that pg_regcomp() had initialized the
      regex_t struct but then failed to allocate any memory for re->re_guts (ie,
      the first malloc call in pg_regcomp() failed).  It would try to touch the
      guts struct anyway, and thus dump core.  This is a sufficiently narrow
      corner case that it's not surprising it's never been seen in the field;
      but still a bug is a bug, so patch all active branches.
      
      Noted while investigating whether we need to call pg_regfree after a
      failure return from pg_regcomp.  Other than this bug, it turns out we
      don't, so adjust comments appropriately.
      1116c9d1
  9. Jul 11, 2012
  10. Jul 10, 2012
    • Tom Lane's avatar
      Back-patch addition of pg_wchar-to-multibyte conversion functionality. · f12960d8
      Tom Lane authored
      Back-patch of commits 72dd6291,
      f6a05fd9, and
      60e9c224.
      
      This is needed to support fixing the regex prefix extraction bug in
      back branches.
      f12960d8
    • Tom Lane's avatar
      Refactor pattern_fixed_prefix() to avoid dealing in incomplete patterns. · 8fc7b07b
      Tom Lane authored
      Previously, pattern_fixed_prefix() was defined to return whatever fixed
      prefix it could extract from the pattern, plus the "rest" of the pattern.
      That definition was sensible for LIKE patterns, but not so much for
      regexes, where reconstituting a valid pattern minus the prefix could be
      quite tricky (certainly the existing code wasn't doing that correctly).
      Since the only thing that callers ever did with the "rest" of the pattern
      was to pass it to like_selectivity() or regex_selectivity(), let's cut out
      the middle-man and just have pattern_fixed_prefix's subroutines do this
      directly.  Then pattern_fixed_prefix can return a simple selectivity
      number, and the question of how to cope with partial patterns is removed
      from its API specification.
      
      While at it, adjust the API spec so that callers who don't actually care
      about the pattern's selectivity (which is a lot of them) can pass NULL for
      the selectivity pointer to skip doing the work of computing a selectivity
      estimate.
      
      This patch is only an API refactoring that doesn't actually change any
      processing, other than allowing a little bit of useless work to be skipped.
      However, it's necessary infrastructure for my upcoming fix to regex prefix
      extraction, because after that change there won't be any simple way to
      identify the "rest" of the regex, not even to the low level of fidelity
      needed by regex_selectivity.  We can cope with that if regex_fixed_prefix
      and regex_selectivity communicate directly, but not if we have to work
      within the old API.  Hence, back-patch to all active branches.
      8fc7b07b
  11. Jul 09, 2012
    • Tom Lane's avatar
      Fix planner to pass correct collation to operator selectivity estimators. · eb1b4881
      Tom Lane authored
      We can do this without creating an API break for estimation functions
      by passing the collation using the existing fmgr functionality for
      passing an input collation as a hidden parameter.
      
      The need for this was foreseen at the outset, but we didn't get around to
      making it happen in 9.1 because of the decision to sort all pg_statistic
      histograms according to the database's default collation.  That meant that
      selectivity estimators generally need to use the default collation too,
      even if they're estimating for an operator that will do something
      different.  The reason it's suddenly become more interesting is that
      regexp interpretation also uses a collation (for its LC_TYPE not LC_COLLATE
      property), and we no longer want to use the wrong collation when examining
      regexps during planning.  It's not that the selectivity estimate is likely
      to change much from this; rather that we are thinking of caching compiled
      regexps during planner estimation, and we won't get the intended benefit
      if we cache them with a different collation than the executor will use.
      
      Back-patch to 9.1, both because the regexp change is likely to get
      back-patched and because we might as well get this right in all
      collation-supporting branches, in case any third-party code wants to
      rely on getting the collation.  The patch turns out to be minuscule
      now that I've done it ...
      eb1b4881
  12. Jul 06, 2012
  13. Jul 05, 2012
  14. Jul 02, 2012
  15. Jul 01, 2012
    • Tom Lane's avatar
      Fix race condition in enum value comparisons. · 972e0666
      Tom Lane authored
      When (re) loading the typcache comparison cache for an enum type's values,
      use an up-to-date MVCC snapshot, not the transaction's existing snapshot.
      This avoids problems if we encounter an enum OID that was created since our
      transaction started.  Per report from Andres Freund and diagnosis by Robert
      Haas.
      
      To ensure this is safe even if enum comparison manages to get invoked
      before we've set a transaction snapshot, tweak GetLatestSnapshot to
      redirect to GetTransactionSnapshot instead of throwing error when
      FirstSnapshotSet is false.  The existing uses of GetLatestSnapshot (in
      ri_triggers.c) don't care since they couldn't be invoked except in a
      transaction that's already done some work --- but it seems just conceivable
      that this might not be true of enums, especially if we ever choose to use
      enums in system catalogs.
      
      Note that the comparable coding in enum_endpoint and enum_range_internal
      remains GetTransactionSnapshot; this is perhaps debatable, but if we
      changed it those functions would have to be marked volatile, which doesn't
      seem attractive.
      
      Back-patch to 9.1 where ALTER TYPE ADD VALUE was added.
      972e0666
  16. Jun 30, 2012
  17. Jun 27, 2012
  18. Jun 14, 2012
    • Tom Lane's avatar
      Revisit error message details for JSON input parsing. · 80edfd76
      Tom Lane authored
      Instead of identifying error locations only by line number (which could
      be entirely unhelpful with long input lines), provide a fragment of the
      input text too, placing this info in a new CONTEXT entry.  Make the
      error detail messages conform more closely to style guidelines, fix
      failure to expose some of them for translation, ensure compiler can
      check formats against supplied parameters.
      80edfd76
  19. Jun 12, 2012
  20. Jun 10, 2012
  21. Jun 05, 2012
    • Tom Lane's avatar
      Fix bogus handling of control characters in json_lex_string(). · 3dd8e596
      Tom Lane authored
      The original coding misbehaved if "char" is signed, and also made the
      extremely poor decision to print control characters literally when trying
      to complain about them.  Report and patch by Shigeru Hanada.
      
      In passing, also fix core dump risk in report_parse_error() should the
      parse state be something other than what it expects.
      3dd8e596
  22. May 31, 2012
    • Tom Lane's avatar
      Ignore SECURITY DEFINER and SET attributes for a PL's call handler. · 33c6eaf7
      Tom Lane authored
      It's not very sensible to set such attributes on a handler function;
      but if one were to do so, fmgr.c went into infinite recursion because
      it would call fmgr_security_definer instead of the handler function proper.
      There is no way for fmgr_security_definer to know that it ought to call the
      handler and not the original function referenced by the FmgrInfo's fn_oid,
      so it tries to do the latter, causing the whole process to start over
      again.
      
      Ordinarily such misconfiguration of a procedural language's handler could
      be written off as superuser error.  However, because we allow non-superuser
      database owners to create procedural languages and the handler for such a
      language becomes owned by the database owner, it is possible for a database
      owner to crash the backend, which ideally shouldn't be possible without
      superuser privileges.  In 9.2 and up we will adjust things so that the
      handler functions are always owned by superusers, but in existing branches
      this is a minor security fix.
      
      Problem noted by Noah Misch (after several of us had failed to detect
      it :-().  This is CVE-2012-2655.
      33c6eaf7
    • Tom Lane's avatar
      Expand the allowed range of timezone offsets to +/-15:59:59 from Greenwich. · cd0ff9c0
      Tom Lane authored
      We used to only allow offsets less than +/-13 hours, then it was +/14,
      then it was +/-15.  That's still not good enough though, as per today's bug
      report from Patric Bechtel.  This time I actually looked through the Olson
      timezone database to find the largest offsets used anywhere.  The winners
      are Asia/Manila, at -15:56:00 until 1844, and America/Metlakatla, at
      +15:13:42 until 1867.  So we'd better allow offsets less than +/-16 hours.
      
      Given the history, we are way overdue to have some greppable #define
      symbols controlling this, so make some ... and also remove an obsolete
      comment that didn't get fixed the last time.
      
      Back-patch to all supported branches.
      cd0ff9c0
  23. May 25, 2012
  24. May 22, 2012
    • Tom Lane's avatar
      Update woefully-obsolete comment. · efae4653
      Tom Lane authored
      The accurate info about what's in a lock file has been in miscadmin.h
      for some time, so let's just make this comment point there instead of
      maintaining a duplicative copy.
      efae4653
  25. May 20, 2012
  26. May 15, 2012
  27. May 14, 2012
  28. May 11, 2012
  29. May 09, 2012
  30. May 03, 2012
  31. May 02, 2012
    • Robert Haas's avatar
      Avoid repeated CLOG access from heap_hot_search_buffer. · 00381104
      Robert Haas authored
      At the time we check whether the tuple is dead to all running
      transactions, we've already verified that it isn't visible to our
      scan, setting hint bits if appropriate.  So there's no need to
      recheck CLOG for the all-dead test we do just a moment later.
      So, add HeapTupleIsSurelyDead() to test the appropriate condition
      under the assumption that all relevant hit bits are already set.
      
      Review by Tom Lane.
      00381104
    • Heikki Linnakangas's avatar
      Remove duplicate words in comments. · f291ccd4
      Heikki Linnakangas authored
      Found these with grep -r "for for ".
      f291ccd4
Loading