From: Heikki Linnakangas Date: Fri, 22 Nov 2024 15:43:04 +0000 (+0200) Subject: Make the memory layout of Port struct independent of USE_OPENSSL X-Git-Tag: REL_18_BETA1~1441 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=8fb5936703e84945766b8425bfe54e0060dea231;p=postgresql.git Make the memory layout of Port struct independent of USE_OPENSSL Commit d39a49c1e4 added new fields to the struct, but missed the "keep these last" comment on the previous fields. Add placeholder variables so that the offsets of the fields are the same whether you build with USE_OPENSSL or not. This is a courtesy to extensions that might peek at the fields, to make the ABI the same regardless of the options used to build PostgreSQL. In reality, I don't expect any extensions to look at the 'raw_buf' fields. Firstly, they are new in v17, so no one's written such extensions yet. Secondly, extensions should have no business poking at those fields anyway. Nevertheless, fix this properly on 'master'. On v17, we mustn't change the memory layout, so just fix the comments. Author: Jacob Champion Discussion: https://www.postgresql.org/message-id/raw/CAOYmi%2BmKVJNzn5_TD_MK%3DhqO64r_w8Gb0FHCLk0oAkW-PJv8jQ@mail.gmail.com --- diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h index d97d1e5f6b2..9109b2c3344 100644 --- a/src/include/libpq/libpq-be.h +++ b/src/include/libpq/libpq-be.h @@ -207,12 +207,17 @@ typedef struct Port bool last_read_was_eof; /* - * OpenSSL structures. (Keep these last so that the locations of other - * fields are the same whether or not you build with SSL enabled.) + * OpenSSL structures. As with GSSAPI above, to keep struct offsets + * constant, NULL pointers are stored when SSL support is not enabled. + * (Although extensions should have no business accessing the raw_buf + * fields anyway.) */ #ifdef USE_OPENSSL SSL *ssl; X509 *peer; +#else + void *ssl; + void *peer; #endif /*