Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-3]: src/usr.sbin/ndbootd Pull up revision 1.9 (requested by lukem...
details: https://anonhg.NetBSD.org/src/rev/241700ad7ab3
branches: netbsd-3
changeset: 576239:241700ad7ab3
user: snj <snj%NetBSD.org@localhost>
date: Wed Jun 15 05:58:16 2005 +0000
description:
Pull up revision 1.9 (requested by lukem in ticket #419):
Rewrite method used to determine the ethernet address of the desired
interface to not use uninitalized variables.
Bug crept in in conversion to getifaddrs().
Detected with gcc -Wuninitalized.
diffstat:
usr.sbin/ndbootd/ndbootd.c | 38 +++++++++++---------------------------
1 files changed, 11 insertions(+), 27 deletions(-)
diffs (91 lines):
diff -r d16f0bcec40f -r 241700ad7ab3 usr.sbin/ndbootd/ndbootd.c
--- a/usr.sbin/ndbootd/ndbootd.c Wed Jun 15 05:55:41 2005 +0000
+++ b/usr.sbin/ndbootd/ndbootd.c Wed Jun 15 05:58:16 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ndbootd.c,v 1.8 2003/08/17 22:34:17 itojun Exp $ */
+/* $NetBSD: ndbootd.c,v 1.8.6.1 2005/06/15 05:58:16 snj Exp $ */
/* ndbootd.c - the Sun Network Disk (nd) daemon: */
@@ -81,7 +81,7 @@
#if 0
static const char _ndbootd_c_rcsid[] = "<<Id: ndbootd.c,v 1.9 2001/06/13 21:19:11 fredette Exp >>";
#else
-__RCSID("$NetBSD: ndbootd.c,v 1.8 2003/08/17 22:34:17 itojun Exp $");
+__RCSID("$NetBSD: ndbootd.c,v 1.8.6.1 2005/06/15 05:58:16 snj Exp $");
#endif
/* includes: */
@@ -206,9 +206,6 @@
{
struct ifreq ifr;
#ifdef HAVE_AF_LINK
- struct ifaddrs *link_ifas[20]; /* FIXME - magic constant. */
- size_t link_ifas_count;
- size_t link_ifas_i;
struct sockaddr_dl *sadl;
#endif /* HAVE_AF_LINK */
struct ndbootd_interface *interface;
@@ -218,24 +215,10 @@
if (getifaddrs(&ifap) != 0) {
return (NULL);
}
-#ifdef HAVE_AF_LINK
- /* start our list of link address ifas: */
- link_ifas_count = 0;
-#endif /* HAVE_AF_LINK */
/* walk the interface list: */
ifa_user = NULL;
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
-#ifdef HAVE_AF_LINK
- /* if this is a hardware address, save it: */
- if (ifa->ifa_addr->sa_family == AF_LINK) {
- if (link_ifas_count < (sizeof(link_ifas) / sizeof(link_ifas[0]))) {
- link_ifas[link_ifas_count++] = ifa;
- }
- continue;
- }
-#endif /* HAVE_AF_LINK */
-
/* ignore this interface if it doesn't do IP: */
if (ifa->ifa_addr->sa_family != AF_INET) {
continue;
@@ -258,12 +241,10 @@
}
}
- if (ifa == NULL)
+ /* if we don't have an interface to return: */
+ if (ifa == NULL || ifa_user == NULL) {
+ freeifaddrs(ifap);
errno = ENOENT;
-
- /* if we don't have an interface to return: */
- if (ifa_user == NULL) {
- freeifaddrs(ifap);
return (NULL);
}
/* start the interface description: */
@@ -274,15 +255,18 @@
/* we must be able to find an AF_LINK ifreq that gives us the
* interface's Ethernet address. */
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
- if (!strcmp(link_ifas[link_ifas_i]->ifa_name,
- ifa_user->ifa_name)) {
- ifa = link_ifas[link_ifas_i];
+ if (ifa->ifa_addr->sa_family != AF_LINK) {
+ continue;
+ }
+ /* if this is the hardware address we want */
+ if (!strcmp(ifa->ifa_name, ifa_user->ifa_name)) {
break;
}
}
if (ifa == NULL) {
freeifaddrs(ifap);
free(interface);
+ errno = ENOENT;
return (NULL);
}
/* copy out the Ethernet address: */
Home |
Main Index |
Thread Index |
Old Index