Skip to content
Snippets Groups Projects
  1. Mar 28, 2016
  2. Feb 08, 2016
  3. Feb 01, 2016
  4. Dec 14, 2015
    • Heikki Linnakangas's avatar
      Fix out-of-memory error handling in ParameterDescription message processing. · 1e23caae
      Heikki Linnakangas authored
      If libpq ran out of memory while constructing the result set, it would hang,
      waiting for more data from the server, which might never arrive. To fix,
      distinguish between out-of-memory error and not-enough-data cases, and give
      a proper error message back to the client on OOM.
      
      There are still similar issues in handling COPY start messages, but let's
      handle that as a separate patch.
      
      Michael Paquier, Amit Kapila and me. Backpatch to all supported versions.
      1e23caae
  5. Dec 01, 2015
    • Tom Lane's avatar
      Use "g" not "f" format in ecpg's PGTYPESnumeric_from_double(). · 74cf6def
      Tom Lane authored
      The previous coding could overrun the provided buffer size for a very large
      input, or lose precision for a very small input.  Adopt the methodology
      that's been in use in the equivalent backend code for a long time.
      
      Per private report from Bas van Schaik.  Back-patch to all supported
      branches.
      74cf6def
  6. Oct 18, 2015
  7. Oct 05, 2015
  8. Sep 19, 2015
  9. Sep 07, 2015
  10. Aug 13, 2015
  11. Aug 12, 2015
  12. Jul 07, 2015
    • Heikki Linnakangas's avatar
      Improve handling of out-of-memory in libpq. · 6d88c1fc
      Heikki Linnakangas authored
      If an allocation fails in the main message handling loop, pqParseInput3
      or pqParseInput2, it should not be treated as "not enough data available
      yet". Otherwise libpq will wait indefinitely for more data to arrive from
      the server, and gets stuck forever.
      
      This isn't a complete fix - getParamDescriptions and getCopyStart still
      have the same issue, but it's a step in the right direction.
      
      Michael Paquier and me. Backpatch to all supported versions.
      6d88c1fc
  13. Jun 15, 2015
  14. Jun 13, 2015
  15. Jun 09, 2015
  16. Jun 01, 2015
  17. May 22, 2015
    • Tom Lane's avatar
      Back-patch libpq support for TLS versions beyond v1. · b78fbfe6
      Tom Lane authored
      Since 7.3.2, libpq has been coded in such a way that the only SSL protocol
      it would allow was TLS v1.  That approach is looking increasingly obsolete.
      In commit 820f08ca we fixed it to allow TLS >= v1, but did not
      back-patch the change at the time, partly out of caution and partly because
      the question was confused by a contemporary server-side change to reject
      the now-obsolete SSL protocol v3.  9.4 has now been out long enough that
      it seems safe to assume the change is OK; hence, back-patch into 9.0-9.3.
      
      (I also chose to back-patch some relevant comments added by commit
      326e1d73, but did *not* change the server behavior; hence, pre-9.4
      servers will continue to allow SSL v3, even though no remotely modern
      client will request it.)
      
      Per gripe from Jan Bilek.
      b78fbfe6
  18. May 20, 2015
    • Tom Lane's avatar
      Revert error-throwing wrappers for the printf family of functions. · 221f7a94
      Tom Lane authored
      This reverts commit 16304a01, except
      for its changes in src/port/snprintf.c; as well as commit
      cac18a76 which is no longer needed.
      
      Fujii Masao reported that the previous commit caused failures in psql on
      OS X, since if one exits the pager program early while viewing a query
      result, psql sees an EPIPE error from fprintf --- and the wrapper function
      thought that was reason to panic.  (It's a bit surprising that the same
      does not happen on Linux.)  Further discussion among the security list
      concluded that the risk of other such failures was far too great, and
      that the one-size-fits-all approach to error handling embodied in the
      previous patch is unlikely to be workable.
      
      This leaves us again exposed to the possibility of the type of failure
      envisioned in CVE-2015-3166.  However, that failure mode is strictly
      hypothetical at this point: there is no concrete reason to believe that
      an attacker could trigger information disclosure through the supposed
      mechanism.  In the first place, the attack surface is fairly limited,
      since so much of what the backend does with format strings goes through
      stringinfo.c or psprintf(), and those already had adequate defenses.
      In the second place, even granting that an unprivileged attacker could
      control the occurrence of ENOMEM with some precision, it's a stretch to
      believe that he could induce it just where the target buffer contains some
      valuable information.  So we concluded that the risk of non-hypothetical
      problems induced by the patch greatly outweighs the security risks.
      We will therefore revert, and instead undertake closer analysis to
      identify specific calls that may need hardening, rather than attempt a
      universal solution.
      
      We have kept the portion of the previous patch that improved snprintf.c's
      handling of errors when it calls the platform's sprintf().  That seems to
      be an unalloyed improvement.
      
      Security: CVE-2015-3166
      221f7a94
  19. May 18, 2015
    • Tom Lane's avatar
      Stamp 9.2.11. · 520fecfa
      Tom Lane authored
      520fecfa
    • Noah Misch's avatar
      Add error-throwing wrappers for the printf family of functions. · 82b7393e
      Noah Misch authored
      All known standard library implementations of these functions can fail
      with ENOMEM.  A caller neglecting to check for failure would experience
      missing output, information exposure, or a crash.  Check return values
      within wrappers and code, currently just snprintf.c, that bypasses the
      wrappers.  The wrappers do not return after an error, so their callers
      need not check.  Back-patch to 9.0 (all supported versions).
      
      Popular free software standard library implementations do take pains to
      bypass malloc() in simple cases, but they risk ENOMEM for floating point
      numbers, positional arguments, large field widths, and large precisions.
      No specification demands such caution, so this commit regards every call
      to a printf family function as a potential threat.
      
      Injecting the wrappers implicitly is a compromise between patch scope
      and design goals.  I would prefer to edit each call site to name a
      wrapper explicitly.  libpq and the ECPG libraries would, ideally, convey
      errors to the caller rather than abort().  All that would be painfully
      invasive for a back-patched security fix, hence this compromise.
      
      Security: CVE-2015-3166
      82b7393e
    • Peter Eisentraut's avatar
      Translation updates · 6f8b6abd
      Peter Eisentraut authored
      Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git
      Source-Git-Hash: 7da40afeb612deb39a77da4071ea1d5800706863
      6f8b6abd
  20. Apr 26, 2015
  21. Apr 25, 2015
    • Noah Misch's avatar
      Build every ECPG library with -DFRONTEND. · 5eab0f13
      Noah Misch authored
      Each of the libraries incorporates src/port files, which often check
      FRONTEND.  Build systems disagreed on whether to build libpgtypes this
      way.  Only libecpg incorporates files that rely on it today.  Back-patch
      to 9.0 (all supported versions) to forestall surprises.
      5eab0f13
  22. Mar 08, 2015
    • Tom Lane's avatar
      Fix documentation for libpq's PQfn(). · ae67e81e
      Tom Lane authored
      The SGML docs claimed that 1-byte integers could be sent or received with
      the "isint" options, but no such behavior has ever been implemented in
      pqGetInt() or pqPutInt().  The in-code documentation header for PQfn() was
      even less in tune with reality, and the code itself used parameter names
      matching neither the SGML docs nor its libpq-fe.h declaration.  Do a bit
      of additional wordsmithing on the SGML docs while at it.
      
      Since the business about 1-byte integers is a clear documentation bug,
      back-patch to all supported branches.
      ae67e81e
  23. Feb 23, 2015
    • Heikki Linnakangas's avatar
      Fix potential deadlock with libpq non-blocking mode. · 22c9c8a7
      Heikki Linnakangas authored
      If libpq output buffer is full, pqSendSome() function tries to drain any
      incoming data. This avoids deadlock, if the server e.g. sends a lot of
      NOTICE messages, and blocks until we read them. However, pqSendSome() only
      did that in blocking mode. In non-blocking mode, the deadlock could still
      happen.
      
      To fix, take a two-pronged approach:
      
      1. Change the documentation to instruct that when PQflush() returns 1, you
      should wait for both read- and write-ready, and call PQconsumeInput() if it
      becomes read-ready. That fixes the deadlock, but applications are not going
      to change overnight.
      
      2. In pqSendSome(), drain the input buffer before returning 1. This
      alleviates the problem for applications that only wait for write-ready. In
      particular, a slow but steady stream of NOTICE messages during COPY FROM
      STDIN will no longer cause a deadlock. The risk remains that the server
      attempts to send a large burst of data and fills its output buffer, and at
      the same time the client also sends enough data to fill its output buffer.
      The application will deadlock if it goes to sleep, waiting for the socket
      to become write-ready, before the server's data arrives. In practice,
      NOTICE messages and such that the server might be sending are usually
      short, so it's highly unlikely that the server would fill its output buffer
      so quickly.
      
      Backpatch to all supported versions.
      22c9c8a7
  24. Feb 21, 2015
    • Tom Lane's avatar
      Fix misparsing of empty value in conninfo_uri_parse_params(). · 83c3115d
      Tom Lane authored
      After finding an "=" character, the pointer was advanced twice when it
      should only advance once.  This is harmless as long as the value after "="
      has at least one character; but if it doesn't, we'd miss the terminator
      character and include too much in the value.
      
      In principle this could lead to reading off the end of memory.  It does not
      seem worth treating as a security issue though, because it would happen on
      client side, and besides client logic that's taking conninfo strings from
      untrusted sources has much worse security problems than this.
      
      Report and patch received off-list from Thomas Fanghaenel.
      Back-patch to 9.2 where the faulty code was introduced.
      83c3115d
  25. Feb 11, 2015
    • Michael Meskes's avatar
      Fixed array handling in ecpg. · 9be9ac42
      Michael Meskes authored
      When ecpg was rewritten to the new protocol version not all variable types
      were corrected. This patch rewrites the code for these types to fix that. It
      also fixes the documentation to correctly tell the status of array handling.
      9be9ac42
  26. Feb 02, 2015
  27. Jan 24, 2015
    • Tom Lane's avatar
      Replace a bunch more uses of strncpy() with safer coding. · 502e5f9c
      Tom Lane authored
      strncpy() has a well-deserved reputation for being unsafe, so make an
      effort to get rid of nearly all occurrences in HEAD.
      
      A large fraction of the remaining uses were passing length less than or
      equal to the known strlen() of the source, in which case no null-padding
      can occur and the behavior is equivalent to memcpy(), though doubtless
      slower and certainly harder to reason about.  So just use memcpy() in
      these cases.
      
      In other cases, use either StrNCpy() or strlcpy() as appropriate (depending
      on whether padding to the full length of the destination buffer seems
      useful).
      
      I left a few strncpy() calls alone in the src/timezone/ code, to keep it
      in sync with upstream (the IANA tzcode distribution).  There are also a
      few such calls in ecpg that could possibly do with more analysis.
      
      AFAICT, none of these changes are more than cosmetic, except for the four
      occurrences in fe-secure-openssl.c, which are in fact buggy: an overlength
      source leads to a non-null-terminated destination buffer and ensuing
      misbehavior.  These don't seem like security issues, first because no stack
      clobber is possible and second because if your values of sslcert etc are
      coming from untrusted sources then you've got problems way worse than this.
      Still, it's undesirable to have unpredictable behavior for overlength
      inputs, so back-patch those four changes to all active branches.
      502e5f9c
  28. Nov 30, 2014
    • Tom Lane's avatar
      Fix minor bugs in commit 30bf4689 et al. · 7b46ef1d
      Tom Lane authored
      Coverity complained that the "else" added to fillPGconn() was unreachable,
      which it was.  Remove the dead code.  In passing, rearrange the tests so as
      not to bother trying to fetch values for options that can't be assigned.
      
      Pre-9.3 did not have that issue, but it did have a "return" that should be
      "goto oom_error" to ensure that a suitable error message gets filled in.
      7b46ef1d
  29. Nov 25, 2014
    • Heikki Linnakangas's avatar
      Allow "dbname" from connection string to be overridden in PQconnectDBParams · 9b468bce
      Heikki Linnakangas authored
      If the "dbname" attribute in PQconnectDBParams contained a connection string
      or URI (and expand_dbname = TRUE), the database name from the connection
      string could not be overridden by a subsequent "dbname" keyword in the
      array. That was not intentional; all other options can be overridden.
      Furthermore, any subsequent "dbname" caused the connection string from the
      first dbname value to be processed again, overriding any values for the same
      options that were given between the connection string and the second dbname
      option.
      
      In the passing, clarify in the docs that only the first dbname option in the
      array is parsed as a connection string.
      
      Alex Shulgin. Backpatch to all supported versions.
      9b468bce
    • Heikki Linnakangas's avatar
      Check return value of strdup() in libpq connection option parsing. · abcab2a6
      Heikki Linnakangas authored
      An out-of-memory in most of these would lead to strange behavior, like
      connecting to a different database than intended, but some would lead to
      an outright segfault.
      
      Alex Shulgin and me. Backpatch to all supported versions.
      abcab2a6
  30. Oct 29, 2014
    • Heikki Linnakangas's avatar
      Reset error message at PQreset() · 1a27fbd0
      Heikki Linnakangas authored
      If you call PQreset() repeatedly, and the connection cannot be
      re-established, the error messages from the failed connection attempts
      kept accumulating in the error string.
      
      Fixes bug #11455 reported by Caleb Epstein. Backpatch to all supported
      versions.
      1a27fbd0
  31. Oct 23, 2014
    • Tom Lane's avatar
      Ensure libpq reports a suitable error message on unexpected socket EOF. · 6fa31d8d
      Tom Lane authored
      The EOF-detection logic in pqReadData was a bit confused about who should
      set up the error message in case the kernel gives us read-ready-but-no-data
      rather than ECONNRESET or some other explicit error condition.  Since the
      whole point of this situation is that the lower-level functions don't know
      there's anything wrong, pqReadData itself must set up the message.  But
      keep the assumption that if an errno was reported, a message was set up at
      lower levels.
      
      Per bug #11712 from Marko Tiikkaja.  It's been like this for a very long
      time, so back-patch to all supported branches.
      6fa31d8d
Loading