Blame SOURCES/freeradius-Don-t-overwrite-ip_hton-af-prefix-in-fr_pton4-6.patch

75e927
From 64ee0b30df59857bce8f0efea019d065cf48c54c Mon Sep 17 00:00:00 2001
75e927
From: Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
75e927
Date: Thu, 18 Dec 2014 22:05:35 +0200
75e927
Subject: [PATCH 2/2] Don't overwrite ip_hton af/prefix in fr_pton4/6
75e927
75e927
Don't overwrite address family and prefix set by ip_hton (which can fall
75e927
back onto other address family) with AF_INET/32 and AF_INET6/128, in
75e927
fr_pton4 and fr_pton6 respectively.
75e927
75e927
This fixes radiusd listening on wrong address data when falling back to
75e927
another address family.
75e927
---
75e927
 src/lib/misc.c | 12 ++++++------
75e927
 1 file changed, 6 insertions(+), 6 deletions(-)
75e927
75e927
diff --git a/src/lib/misc.c b/src/lib/misc.c
75e927
index ad27057..cf49917 100644
75e927
--- a/src/lib/misc.c
75e927
+++ b/src/lib/misc.c
75e927
@@ -238,6 +238,9 @@ int fr_pton4(fr_ipaddr_t *out, char const *value, size_t inlen, bool resolve, bo
75e927
 	 *	192.0.2.2 is parsed as if it was /32
75e927
 	 */
75e927
 	if (!p) {
75e927
+		out->prefix = 32;
75e927
+		out->af = AF_INET;
75e927
+
75e927
 		/*
75e927
 		 *	Allow '*' as the wildcard address usually 0.0.0.0
75e927
 		 */
75e927
@@ -258,9 +261,6 @@ int fr_pton4(fr_ipaddr_t *out, char const *value, size_t inlen, bool resolve, bo
75e927
 			}
75e927
 		} else if (ip_hton(out, AF_INET, value, fallback) < 0) return -1;
75e927
 
75e927
-		out->prefix = 32;
75e927
-		out->af = AF_INET;
75e927
-
75e927
 		return 0;
75e927
 	}
75e927
 
75e927
@@ -338,6 +338,9 @@ int fr_pton6(fr_ipaddr_t *out, char const *value, size_t inlen, bool resolve, bo
75e927
 
75e927
 	p = strchr(value, '/');
75e927
 	if (!p) {
75e927
+		out->prefix = 128;
75e927
+		out->af = AF_INET6;
75e927
+
75e927
 		/*
75e927
 		 *	Allow '*' as the wildcard address
75e927
 		 */
75e927
@@ -350,9 +353,6 @@ int fr_pton6(fr_ipaddr_t *out, char const *value, size_t inlen, bool resolve, bo
75e927
 			}
75e927
 		} else if (ip_hton(out, AF_INET6, value, fallback) < 0) return -1;
75e927
 
75e927
-		out->prefix = 128;
75e927
-		out->af = AF_INET6;
75e927
-
75e927
 		return 0;
75e927
 	}
75e927
 
75e927
-- 
75e927
2.1.3
75e927