pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Introduce safer encoding and decoding routines for base64.c
Date: Thu, 04 Jul 2019 07:12:48 +0000
Message-ID: <E1hivvE-0002Vp-6Q@gemulon.postgresql.org> (raw)

Introduce safer encoding and decoding routines for base64.c

This is a follow-up refactoring after 09ec55b and b674211, which has
proved that the encoding and decoding routines used by SCRAM have a
poor interface when it comes to check after buffer overflows.  This adds
an extra argument in the shape of the length of the result buffer for
each routine, which is used for overflow checks when encoding or
decoding an input string.  The original idea comes from Tom Lane.

As a result of that, the encoding routine can now fail, so all its
callers are adjusted to generate proper error messages in case of
problems.

On failure, the result buffer gets zeroed.

Author: Michael Paquier
Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/20190623132535.GB1628@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/cfc40d384ae51ea2886d599d2008ae57b529e6ea

Modified Files
--------------
src/backend/libpq/auth-scram.c       | 74 +++++++++++++++++++++++++++---------
src/common/base64.c                  | 59 ++++++++++++++++++++++++----
src/common/scram-common.c            | 59 +++++++++++++++++++++++++---
src/include/common/base64.h          |  4 +-
src/interfaces/libpq/fe-auth-scram.c | 60 +++++++++++++++++++++++------
5 files changed, 210 insertions(+), 46 deletions(-)



Message-ID: <E1hivvE-0002Vp-6Q@gemulon.postgresql.org>
Permalink:  ../E1hivvE-0002Vp-6Q@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hivvE-0002Vp-6Q@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: michael@paquier.xyz
  Subject: Re: pgsql: Introduce safer encoding and decoding routines for base64.c
  In-Reply-To: <E1hivvE-0002Vp-6Q@gemulon.postgresql.org>
  References: <E1hivvE-0002Vp-6Q@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