aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-secure-openssl.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-05-13 10:53:19 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-05-13 10:53:19 -0400
commitddf927fb13471bec0cc76794eaf552df8a1178fb (patch)
treee49de61fffb10e0524461feb20d98ca3dece0c7c /src/interfaces/libpq/fe-secure-openssl.c
parentcc866941ad4583f07e5637c145f6f6ee8a573e11 (diff)
downloadpostgresql-ddf927fb13471bec0cc76794eaf552df8a1178fb.tar.gz
postgresql-ddf927fb13471bec0cc76794eaf552df8a1178fb.zip
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
Diffstat (limited to 'src/interfaces/libpq/fe-secure-openssl.c')
-rw-r--r--src/interfaces/libpq/fe-secure-openssl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index f634c99ca60..b62b4969698 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -264,7 +264,7 @@ rloop:
bool
pgtls_read_pending(PGconn *conn)
{
- return SSL_pending(conn->ssl);
+ return SSL_pending(conn->ssl) > 0;
}
ssize_t