pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't assume GSSAPI result strings are null-terminated.
Date: Wed, 23 Jun 2021 18:01:54 +0000
Message-ID: <E1lw7CE-0002yR-VB@gemulon.postgresql.org> (raw)

Don't assume GSSAPI result strings are null-terminated.

Our uses of gss_display_status() and gss_display_name() assumed
that the gss_buffer_desc strings returned by those functions are
null-terminated.  It appears that they generally are, given the
lack of field complaints up to now.  However, the available
documentation does not promise this, and some man pages
for gss_display_status() show examples that rely on the
gss_buffer_desc.length field instead of expecting null
termination.  Also, we now have a report that on some
implementations, clang's address sanitizer is of the opinion
that the byte after the specified length is undefined.

Hence, change the code to rely on the length field instead.

This might well be cosmetic rather than fixing any real bug, but
it's hard to be sure, so back-patch to all supported branches.
While here, also back-patch the v12 changes that made pg_GSS_error
deal honestly with multiple messages available from
gss_display_status.

Per report from Sudheer H R.

Discussion: https://postgr.es/m/5372B6D4-8276-42C0-B8FB-BD0918826FC3@tekenlight.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/126cdaf47af275f76b2f2ddb023bfdc6f018ae30

Modified Files
--------------
src/backend/libpq/auth.c                | 27 ++++++++++++++++++---------
src/backend/libpq/be-gssapi-common.c    | 11 ++++++-----
src/interfaces/libpq/fe-gssapi-common.c |  3 ++-
3 files changed, 26 insertions(+), 15 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1lw7CE-0002yR-VB@gemulon.postgresql.org>
Permalink:  ../E1lw7CE-0002yR-VB@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lw7CE-0002yR-VB@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Don't assume GSSAPI result strings are null-terminated.
  In-Reply-To: <E1lw7CE-0002yR-VB@gemulon.postgresql.org>
  References: <E1lw7CE-0002yR-VB@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox