rp-pppoe couldn't find the interfaces' Ethernet address with the old

code, as this used the NetBSD<5-style variable effective ifreq length.
The patched code works in old and new compilation environments. Patch
optimized by gimpy@.
This commit is contained in:
is 2012-08-23 13:10:52 +00:00
parent 7b9b3b2611
commit 72cb1a8bcc
3 changed files with 34 additions and 8 deletions

View file

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.39 2010/02/19 18:41:39 joerg Exp $
# $NetBSD: Makefile,v 1.40 2012/08/23 13:10:52 is Exp $
DISTNAME= rp-pppoe-3.8
PKGREVISION= 1
PKGREVISION= 2
CATEGORIES= net
MASTER_SITES= http://www.roaringpenguin.com/files/download/

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.11 2006/11/01 15:17:13 martin Exp $
$NetBSD: distinfo,v 1.12 2012/08/23 13:10:52 is Exp $
SHA1 (rp-pppoe-3.8.tar.gz) = d9a4346701e580b4a6049a940557b38533f9e8f7
RMD160 (rp-pppoe-3.8.tar.gz) = 039798154acae9e7a066172f23904d766ba68a9a
@ -8,4 +8,4 @@ SHA1 (patch-ab) = a3b409352334ca11c9716a864404ccce90511051
SHA1 (patch-af) = a44803519081769250af1f15d64cfd9a9b3834ca
SHA1 (patch-ag) = 6ee706683df96ff7fb0aa5a93626265c2177d543
SHA1 (patch-ah) = 35cf47b00ad6df122de6e84f36eb844201c0d16b
SHA1 (patch-ai) = 81568491692492c3ee564199882247004c4c47d7
SHA1 (patch-ai) = d9cbe1ab1cab0932e5d598fbcd6e57b887239d1c

View file

@ -1,8 +1,8 @@
$NetBSD: patch-ai,v 1.1 2006/11/01 15:17:14 martin Exp $
$NetBSD: patch-ai,v 1.2 2012/08/23 13:10:52 is Exp $
--- src/if.c.orig 2006-04-02 16:29:42.000000000 +0200
+++ src/if.c 2006-11-01 12:15:52.000000000 +0100
@@ -99,7 +99,7 @@
--- src/if.c.orig 2006-04-02 14:29:42.000000000 +0000
+++ src/if.c
@@ -99,7 +99,7 @@ static int dl_addrlen;
static unsigned char *bpfBuffer; /* Packet filter buffer */
static int bpfLength = 0; /* Packet filter buffer length */
@ -11,3 +11,29 @@ $NetBSD: patch-ai,v 1.1 2006/11/01 15:17:14 martin Exp $
static int bpfOffset = 0; /* Current offset in bpfBuffer */
#endif
@@ -152,7 +152,7 @@ getHWaddr(int sock, char const *ifname,
const struct sockaddr_dl *sdl;
struct ifconf ifc;
struct ifreq ifreq, *ifr;
- int i;
+ int i,l;
int found = 0;
ifc.ifc_len = sizeof(inbuf);
@@ -164,10 +164,12 @@ getHWaddr(int sock, char const *ifname,
ifreq.ifr_name[0] = '\0';
for (i = 0; i < ifc.ifc_len; ) {
ifr = (struct ifreq *)((caddr_t)ifc.ifc_req + i);
- i += sizeof(ifr->ifr_name) +
- (ifr->ifr_addr.sa_len > sizeof(struct sockaddr)
- ? ifr->ifr_addr.sa_len
- : sizeof(struct sockaddr));
+
+ l = sizeof(*ifr);
+ if (sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len > l)
+ l = sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len;
+ i += l;
+
if (ifr->ifr_addr.sa_family == AF_LINK) {
sdl = (const struct sockaddr_dl *) &ifr->ifr_addr;
if ((sdl->sdl_type == IFT_ETHER) &&