[Pkg-sysvinit-commits] r1413 - in sysvinit-upstream/trunk: doc src
Petter Reinholdtsen
pere at alioth.debian.org
Fri Jul 10 19:33:03 UTC 2009
Author: pere
Date: 2009-07-10 19:33:02 +0000 (Fri, 10 Jul 2009)
New Revision: 1413
Modified:
sysvinit-upstream/trunk/doc/Changelog
sysvinit-upstream/trunk/src/last.c
Log:
Improve handling of IPv6 addresses in last. Patch from Fedora.
Modified: sysvinit-upstream/trunk/doc/Changelog
===================================================================
--- sysvinit-upstream/trunk/doc/Changelog 2009-07-10 19:31:30 UTC (rev 1412)
+++ sysvinit-upstream/trunk/doc/Changelog 2009-07-10 19:33:02 UTC (rev 1413)
@@ -10,6 +10,7 @@
of uptime too. In shutdown lines print downtimes rather than
the time between downs. Fix typo in string compare in last.c.
Patch by Thomas Hood.
+ * Improve handling of IPv6 addresses in last. Patch from Fedora.
-- Petter Reinholdtsen <pere at debian.org> Fri, 30 Jul 2004 14:14:58 +0200
Modified: sysvinit-upstream/trunk/src/last.c
===================================================================
--- sysvinit-upstream/trunk/src/last.c 2009-07-10 19:31:30 UTC (rev 1412)
+++ sysvinit-upstream/trunk/src/last.c 2009-07-10 19:33:02 UTC (rev 1413)
@@ -307,14 +307,15 @@
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. Outside of
- * that is illegal and must be IPv4.
+ * 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
*
@@ -323,7 +324,11 @@
if (a[0] == 0 && a[1] == 0 && a[2] == htonl (0xffff))
mapped = 1;
topnibble = ntohl((unsigned int)a[0]) >> 28;
- if (topnibble < 2 || topnibble > 3 || mapped ||
+
+ 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)) {
/* IPv4 */
sin.sin_family = AF_INET;
More information about the Pkg-sysvinit-commits
mailing list