diff options
author | Heikki Linnakangas | 2024-04-29 09:26:46 +0000 |
---|---|---|
committer | Heikki Linnakangas | 2024-04-29 09:26:46 +0000 |
commit | 3c184092651b0b15ca1207c154ab3fd055e1e9fe (patch) | |
tree | e153b3c8c9af32ab912e11c2539d61998724f5c3 | |
parent | 592a2283721f7143999364ef487f2b4993f5161d (diff) |
libpq: If ALPN is not used, make PQsslAttribute(conn, "alpn") == ""
The documentation says that PQsslAttribute(conn, "alpn") returns an
empty string if ALPN is not used, but the code actually returned
NULL. Fix the code to match the documentation.
Reported-by: Michael Paquier
Discussion: https://www.postgresql.org/message-id/[email protected]
-rw-r--r-- | src/bin/psql/command.c | 2 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-secure-openssl.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 288c1a8c93..fae5940b54 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3896,7 +3896,7 @@ printSSLInfo(void) protocol ? protocol : _("unknown"), cipher ? cipher : _("unknown"), (compression && strcmp(compression, "off") != 0) ? _("on") : _("off"), - alpn ? alpn : _("none")); + (alpn && alpn[0] != '\0') ? alpn : _("none")); } /* diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index e7a4d006e1..33362000d3 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -1837,7 +1837,7 @@ PQsslAttribute(PGconn *conn, const char *attribute_name) SSL_get0_alpn_selected(conn->ssl, &data, &len); if (data == NULL || len == 0 || len > sizeof(alpn_str) - 1) - return NULL; + return ""; memcpy(alpn_str, data, len); alpn_str[len] = 0; return alpn_str; |