From 9a05edd2ec22a5e7fc2a832e9baf3f361aad92a7 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Mon, 11 May 2015 09:45:00 +0200 Subject: [PATCH] radius: corrected the byte ordering of NAS_IP_ADDRESS --- src/acct/radius.c | 12 +++++++----- src/auth/radius.c | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/acct/radius.c b/src/acct/radius.c index 97460084..72fc9bd6 100644 --- a/src/acct/radius.c +++ b/src/acct/radius.c @@ -121,12 +121,14 @@ static void append_acct_standard(rc_handle *rh, const common_auth_info_st *ai, V } if (ai->our_ip[0] != 0) { - struct sockaddr_storage st; + struct in_addr in; + struct in6_addr in6; - if (inet_pton(AF_INET, ai->our_ip, &st) != 0) { - rc_avpair_add(rh, send, PW_NAS_IP_ADDRESS, (char*)&st, sizeof(struct in_addr), 0); - } else if (inet_pton(AF_INET6, ai->our_ip, &st) != 0) { - rc_avpair_add(rh, send, PW_NAS_IPV6_ADDRESS, (char*)&st, sizeof(struct in6_addr), 0); + if (inet_pton(AF_INET, ai->our_ip, &in) != 0) { + in.s_addr = ntohl(in.s_addr); + rc_avpair_add(rh, send, PW_NAS_IP_ADDRESS, (char*)&in, sizeof(struct in_addr), 0); + } else if (inet_pton(AF_INET6, ai->our_ip, &in6) != 0) { + rc_avpair_add(rh, send, PW_NAS_IPV6_ADDRESS, (char*)&in6, sizeof(struct in6_addr), 0); } } diff --git a/src/auth/radius.c b/src/auth/radius.c index c458f137..3594eb81 100644 --- a/src/auth/radius.c +++ b/src/auth/radius.c @@ -212,12 +212,14 @@ static int radius_auth_pass(void *ctx, const char *pass, unsigned pass_len) } if (pctx->our_ip[0] != 0) { - struct sockaddr_storage st; + struct in_addr in; + struct in6_addr in6; - if (inet_pton(AF_INET, pctx->our_ip, &st) != 0) { - rc_avpair_add(rh, &send, PW_NAS_IP_ADDRESS, (char*)&st, sizeof(struct in_addr), 0); - } else if (inet_pton(AF_INET6, pctx->our_ip, &st) != 0) { - rc_avpair_add(rh, &send, PW_NAS_IPV6_ADDRESS, (char*)&st, sizeof(struct in6_addr), 0); + if (inet_pton(AF_INET, pctx->our_ip, &in) != 0) { + in.s_addr = ntohl(in.s_addr); + rc_avpair_add(rh, &send, PW_NAS_IP_ADDRESS, (char*)&in, sizeof(struct in_addr), 0); + } else if (inet_pton(AF_INET6, pctx->our_ip, &in6) != 0) { + rc_avpair_add(rh, &send, PW_NAS_IPV6_ADDRESS, (char*)&in6, sizeof(struct in6_addr), 0); } }