pgsql: Fix misuse of an integer as a bool.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix misuse of an integer as a bool.
Date: 2019-05-13 14:53:33
Message-ID: E1hQCKb-0007ii-Oi@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix misuse of an integer as a bool.

pgtls_read_pending is declared to return bool, but what the underlying
SSL_pending function returns is a count of available bytes.

This is actually somewhat harmless if we're using C99 bools, but in
the back branches it's a live bug: if the available-bytes count happened
to be a multiple of 256, it would get converted to a zero char value.
On machines where char is signed, counts of 128 and up could misbehave
as well. The net effect is that when using SSL, libpq might block
waiting for data even though some has already been received.

Broken by careless refactoring in commit 4e86f1b16, so back-patch
to 9.5 where that came in.

Per bug #15802 from David Binderman.

Discussion: https://postgr.es/m/15802-f0911a97f0346526@postgresql.org

Branch
------
REL_10_STABLE

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

Modified Files
--------------
src/interfaces/libpq/fe-misc.c | 2 +-
src/interfaces/libpq/fe-secure-openssl.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2019-05-13 17:20:25 pgsql: Improve comment for att_isnull.
Previous Message Etsuro Fujita 2019-05-13 08:41:29 pgsql: postgres_fdw: Fix typo in comment.