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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't assume GSSAPI result strings are null-terminated.
Date: 2021-06-23 18:01:55
Message-ID: E1lw7CF-0002ye-0y@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/006a829b2d1427974a4d7ae58f1191be2d0ae705

Modified Files
--------------
src/backend/libpq/auth.c | 100 +++++++++++++++++++++++++++--------------
src/interfaces/libpq/fe-auth.c | 4 +-
2 files changed, 69 insertions(+), 35 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-06-23 18:27:33 pgsql: Doc: fix confusion about LEAKPROOF in syntax summaries.
Previous Message Tom Lane 2021-06-23 18:01:54 pgsql: Don't assume GSSAPI result strings are null-terminated.