forked from gooselinux/sysvinit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysvinit-2.87-ipv6.patch
40 lines (37 loc) · 1.22 KB
/
sysvinit-2.87-ipv6.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
diff --git a/src/last.c b/src/last.c
index 06bba47..09241ef 100644
--- a/src/last.c
+++ b/src/last.c
@@ -309,30 +309,22 @@ int dns_lookup(char *result, int size, int useip, int32_t *a)
struct sockaddr_in6 sin6;
struct sockaddr *sa;
int salen, flags;
- unsigned int topnibble;
- unsigned int azero = 0, sitelocal = 0;
int mapped = 0;
flags = useip ? NI_NUMERICHOST : 0;
/*
- * IPv4 or IPv6 ? We use 2 heuristics:
- * 1. Current IPv6 range uses 2000-3fff or fec0-feff.
- * Outside of that is illegal and must be IPv4.
- * 2. If last 3 bytes are 0, must be IPv4
- * 3. If IPv6 in IPv4, handle as IPv4
+ * IPv4 or IPv6 ?
+ * 1. If last 3 4bytes are 0, must be IPv4
+ * 2. If IPv6 in IPv4, handle as IPv4
+ * 3. Anything else is IPv6
*
* Ugly.
*/
if (a[0] == 0 && a[1] == 0 && a[2] == htonl (0xffff))
mapped = 1;
- topnibble = ntohl((unsigned int)a[0]) >> 28;
- azero = ntohl((unsigned int)a[0]) >> 16;
- sitelocal = (azero >= 0xfec0 && azero <= 0xfeff) ? 1 : 0;
-
- if (((topnibble < 2 || topnibble > 3) && (!sitelocal)) || mapped ||
- (a[1] == 0 && a[2] == 0 && a[3] == 0)) {
+ if (mapped || (a[1] == 0 && a[2] == 0 && a[3] == 0)) {
/* IPv4 */
sin.sin_family = AF_INET;
sin.sin_port = 0;