From a1bddc53c34047944c6a0a105f4689e042c6c64c 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 52a7ed3..1f3aa83 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);