From cc3f6702afdea7e9a20983810c19f5cc58eaf5e8 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 19 Jan 2023 08:00:00 +0000 Subject: pam_client.h: silence compiler warning gcc-12 insists on issuing the following warning: In file included from libpamc.h:13, from pamc_converse.c:9: pamc_converse.c: In function 'pamc_converse': include/security/pam_client.h:129:27: error: array subscript 'struct [0]' is partly outside array bounds of 'unsigned char[6]' [-Werror=array-bounds] 129 | (*(old_p))->control = cntrl; \ | ^~ pamc_converse.c:209:5: note: in expansion of macro 'PAM_BP_RENEW' 209 | PAM_BP_RENEW(prompt_p, PAM_BPC_FAIL, 0); | ^~~~~~~~~~~~ include/security/pam_client.h:87:29: note: object of size 6 allocated by 'calloc' 87 | # define PAM_BP_CALLOC calloc | ^ include/security/pam_client.h:124:29: note: in expansion of macro 'PAM_BP_CALLOC' 124 | if ((*(old_p) = PAM_BP_CALLOC(1, 1+__size))) { \ | ^~~~~~~~~~~~~ pamc_converse.c:209:5: note: in expansion of macro 'PAM_BP_RENEW' 209 | PAM_BP_RENEW(prompt_p, PAM_BPC_FAIL, 0); | ^~~~~~~~~~~~ * libpamc/include/security/pam_client.h (pamc_bp_t): Decorate the structure pointed by pamc_bp_t pointer as packed. Despite being a part of the API, the structure is not supposed to be used directly, and all the interface macros were assuming from the very beginning that this structure is packed. --- libpamc/include/security/pam_client.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libpamc') diff --git a/libpamc/include/security/pam_client.h b/libpamc/include/security/pam_client.h index 41f83da6..0fc2cf44 100644 --- a/libpamc/include/security/pam_client.h +++ b/libpamc/include/security/pam_client.h @@ -24,7 +24,8 @@ extern "C" { typedef struct pamc_handle_s *pamc_handle_t; /* binary prompt structure pointer */ -typedef struct { uint32_t length; uint8_t control; } *pamc_bp_t; +typedef struct { uint32_t length; uint8_t control; } + __attribute__ ((__packed__)) *pamc_bp_t; /* * functions provided by libpamc -- cgit v1.2.3