Skip to content

Commit

Permalink
do not consider opaque type of s_addr as int
Browse files Browse the repository at this point in the history
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 <linux/in.h> :
	/* Internet address. */
	struct in_addr {
		__be32	s_addr;
	};
  • Loading branch information
DimitriPapadopoulos committed Apr 6, 2024
1 parent e46db2e commit e093685
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pam_radius_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e093685

Please sign in to comment.