]> granicus.if.org Git - postgresql/commit
Fix misuse of an integer as a bool.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 13 May 2019 14:53:19 +0000 (10:53 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 13 May 2019 14:53:19 +0000 (10:53 -0400)
commite3bf3c0f8c9c880ba808bc11c2825ecba720e4ed
treeacd131f5c25b20c1652ae61da77a2aa9f262ba77
parent7c16a2bfdcd8d477c8ff39c5eeb7d3b87fe0d60b
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
src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/fe-secure-openssl.c