From e0936855f60b2c56ec7c256a5bf9af9edb7b57cb Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:38:44 +0200 Subject: [PATCH] do not consider opaque type of `s_addr` as `int` The current code implies `int` is 4 bytes - which it is on current Linux platforms - and that `attr_fip->data` is aligned - which I presume it is. Neverthless, it might be clearer to use memcpy() here. From the Linux header : /* Internet address. */ struct in_addr { __be32 s_addr; }; --- src/pam_radius_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pam_radius_auth.c b/src/pam_radius_auth.c index 6338d9d..b6f8a6d 100644 --- a/src/pam_radius_auth.c +++ b/src/pam_radius_auth.c @@ -1581,7 +1581,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg char frameip[sizeof(name) + INET_ADDRSTRLEN]; struct in_addr ip_addr; - ip_addr.s_addr = *(int*) attr_fip->data; + memcpy(&ip_addr.s_addr, attr_fip->data, 4); snprintf(frameip, sizeof(frameip), "%s=%s", name, inet_ntoa(ip_addr)); retval = pam_putenv(pamh, frameip);