diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-09-29 17:28:09 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-09-29 17:28:09 -0400 |
commit | cae4688ce81b8449aa6e1e7bfa384d53520a81fb (patch) | |
tree | 93748024b0d30bf6796b101390bb09f75a987c77 /src | |
parent | d460faf00285fd99d3c80e890c8f6fe798233b48 (diff) |
Fix bogus behavior of PQsslAttribute(conn, "library").
Commit ebc8b7d44 intended to change the behavior of
PQsslAttribute(NULL, "library"), but accidentally also changed
what happens with a non-NULL conn pointer. Undo that so that
only the intended behavior change happens. Clarify some
associated documentation.
Per bug #17625 from Heath Lord. Back-patch to v15.
Discussion: https://postgr.es/m/17625-fc47c78b7d71b534@postgresql.org
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/libpq/fe-secure-openssl.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index 3cc75380e02..fe1e98a3b0d 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -1747,14 +1747,21 @@ PQsslAttributeNames(PGconn *conn) const char * PQsslAttribute(PGconn *conn, const char *attribute_name) { - if (strcmp(attribute_name, "library") == 0) - return "OpenSSL"; - if (!conn) + { + /* PQsslAttribute(NULL, "library") reports the default SSL library */ + if (strcmp(attribute_name, "library") == 0) + return "OpenSSL"; return NULL; + } + + /* All attributes read as NULL for a non-encrypted connection */ if (conn->ssl == NULL) return NULL; + if (strcmp(attribute_name, "library") == 0) + return "OpenSSL"; + if (strcmp(attribute_name, "key_bits") == 0) { static char sslbits_str[12]; |