summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/get_myaddress.c
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1996-11-22 23:37:08 +0000
committerpst <pst@FreeBSD.org>1996-11-22 23:37:08 +0000
commitb63c62d83045f7979db1916dce8aa337236c009a (patch)
tree6089f523f4eb1ff1246b523c15b020ec78fb5b3b /lib/libc/rpc/get_myaddress.c
parent97e74970338f7982d4161f25b38763eda5e2394c (diff)
downloadFreeBSD-src-b63c62d83045f7979db1916dce8aa337236c009a.zip
FreeBSD-src-b63c62d83045f7979db1916dce8aa337236c009a.tar.gz
get_myaddress() wasn't following the interface array properly
Cannidate for: 2.2
Diffstat (limited to 'lib/libc/rpc/get_myaddress.c')
-rw-r--r--lib/libc/rpc/get_myaddress.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/libc/rpc/get_myaddress.c b/lib/libc/rpc/get_myaddress.c
index c93671b..3740094 100644
--- a/lib/libc/rpc/get_myaddress.c
+++ b/lib/libc/rpc/get_myaddress.c
@@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$Id: get_myaddress.c,v 1.3 1995/10/22 14:51:23 phk Exp $";
+static char *rcsid = "$Id: get_myaddress.c,v 1.4 1996/06/08 22:54:51 jraynard Exp $";
#endif
/*
@@ -60,8 +60,7 @@ void get_myaddress(addr)
int s;
char buf[BUFSIZ];
struct ifconf ifc;
- struct ifreq ifreq, *ifr;
- int len, slop;
+ struct ifreq ifreq, *ifr, *end;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("get_myaddress: socket");
@@ -74,7 +73,9 @@ void get_myaddress(addr)
exit(1);
}
ifr = ifc.ifc_req;
- for (len = ifc.ifc_len; len; len -= sizeof ifreq) {
+ end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
+
+ while (ifr < end) {
ifreq = *ifr;
if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
perror("get_myaddress: ioctl");
@@ -86,14 +87,10 @@ void get_myaddress(addr)
addr->sin_port = htons(PMAPPORT);
break;
}
- /*
- * Deal with variable length addresses
- */
- slop = ifr->ifr_addr.sa_len - sizeof (struct sockaddr);
- if (slop) {
- ifr = (struct ifreq *) ((caddr_t)ifr + slop);
- len -= slop;
- }
+ if (ifr->ifr_addr.sa_len)
+ ifr = (struct ifreq *) ((caddr_t) ifr +
+ ifr->ifr_addr.sa_len -
+ sizeof(struct sockaddr));
ifr++;
}
(void) close(s);
OpenPOWER on IntegriCloud