Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3c18409

Browse files
committed
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/ZideNHji0G4gxmc3@paquier.xyz
1 parent 592a228 commit 3c18409

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/bin/psql/command.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3896,7 +3896,7 @@ printSSLInfo(void)
38963896
protocol ? protocol : _("unknown"),
38973897
cipher ? cipher : _("unknown"),
38983898
(compression && strcmp(compression, "off") != 0) ? _("on") : _("off"),
3899-
alpn ? alpn : _("none"));
3899+
(alpn && alpn[0] != '\0') ? alpn : _("none"));
39003900
}
39013901

39023902
/*

src/interfaces/libpq/fe-secure-openssl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
18371837

18381838
SSL_get0_alpn_selected(conn->ssl, &data, &len);
18391839
if (data == NULL || len == 0 || len > sizeof(alpn_str) - 1)
1840-
return NULL;
1840+
return "";
18411841
memcpy(alpn_str, data, len);
18421842
alpn_str[len] = 0;
18431843
return alpn_str;

0 commit comments

Comments
 (0)