Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig more fix to SIOCGIFCONF alignment.
details: https://anonhg.NetBSD.org/src/rev/47f4877638e6
branches: trunk
changeset: 482645:47f4877638e6
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Feb 18 08:14:26 2000 +0000
description:
more fix to SIOCGIFCONF alignment.
diffstat:
sbin/ifconfig/ifconfig.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diffs (50 lines):
diff -r ffc85d7a547e -r 47f4877638e6 sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c Fri Feb 18 06:54:47 2000 +0000
+++ b/sbin/ifconfig/ifconfig.c Fri Feb 18 08:14:26 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ifconfig.c,v 1.67 2000/01/25 06:11:25 mycroft Exp $ */
+/* $NetBSD: ifconfig.c,v 1.68 2000/02/18 08:14:26 itojun Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
#if 0
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#else
-__RCSID("$NetBSD: ifconfig.c,v 1.67 2000/01/25 06:11:25 mycroft Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.68 2000/02/18 08:14:26 itojun Exp $");
#endif
#endif /* not lint */
@@ -630,10 +630,11 @@
ifr = ifc.ifc_req;
for (i = 0; i < ifc.ifc_len; ) {
ifr = (struct ifreq *)((caddr_t)ifc.ifc_req + i);
- siz = sizeof(ifr->ifr_name) +
- (ifr->ifr_addr.sa_len > sizeof(struct sockaddr)
- ? ifr->ifr_addr.sa_len
- : sizeof(struct sockaddr));
+ memcpy(ifrbuf, ifr, sizeof(*ifr));
+ siz = ((struct ifreq *)ifrbuf)->ifr_addr.sa_len;
+ if (siz < sizeof(ifr->ifr_addr))
+ siz = sizeof(ifr->ifr_addr);
+ siz += sizeof(ifr->ifr_name);
i += siz;
/* avoid alignment issue */
if (sizeof(ifrbuf) < siz)
@@ -675,10 +676,11 @@
ifreq.ifr_name[0] = '\0';
for (i = 0, idx = 0; i < ifc.ifc_len; ) {
ifr = (struct ifreq *)((caddr_t)ifc.ifc_req + i);
- siz = sizeof(ifr->ifr_name) +
- (ifr->ifr_addr.sa_len > sizeof(struct sockaddr)
- ? ifr->ifr_addr.sa_len
- : sizeof(struct sockaddr));
+ memcpy(ifrbuf, ifr, sizeof(*ifr));
+ siz = ((struct ifreq *)ifrbuf)->ifr_addr.sa_len;
+ if (siz < sizeof(ifr->ifr_addr))
+ siz = sizeof(ifr->ifr_addr);
+ siz += sizeof(ifr->ifr_name);
i += siz;
/* avoid alignment issue */
if (sizeof(ifrbuf) < siz)
Home |
Main Index |
Thread Index |
Old Index