Allocate flagreq on stack.

This commit is contained in:
enami 2000-04-20 02:08:55 +00:00
parent f3d36a14e8
commit 16fcce9bb7
1 changed files with 18 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ifconfig.c,v 1.78 2000/04/13 07:39:57 itojun Exp $ */ /* $NetBSD: ifconfig.c,v 1.79 2000/04/20 02:08:55 enami Exp $ */
/*- /*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@ -80,7 +80,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#else #else
__RCSID("$NetBSD: ifconfig.c,v 1.78 2000/04/13 07:39:57 itojun Exp $"); __RCSID("$NetBSD: ifconfig.c,v 1.79 2000/04/20 02:08:55 enami Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -124,7 +124,7 @@ __RCSID("$NetBSD: ifconfig.c,v 1.78 2000/04/13 07:39:57 itojun Exp $");
#include <ifaddrs.h> #include <ifaddrs.h>
#endif #endif
struct ifreq ifr, flagreq, ridreq; struct ifreq ifr, ridreq;
struct ifaliasreq addreq __attribute__((aligned(4))); struct ifaliasreq addreq __attribute__((aligned(4)));
#ifdef INET6 #ifdef INET6
struct in6_ifreq ifr6; struct in6_ifreq ifr6;
@ -348,6 +348,7 @@ main(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
{ {
struct ifreq ifreq;
int ch; int ch;
/* Parse command-line options */ /* Parse command-line options */
@ -555,8 +556,13 @@ main(argc, argv)
if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0) if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0)
warn("SIOCAIFADDR"); warn("SIOCAIFADDR");
} }
if (reset_if_flags && ioctl(s, SIOCSIFFLAGS, (caddr_t)&flagreq) < 0)
err(1, "SIOCSIFFLAGS"); if (reset_if_flags) {
(void) strncpy(ifreq.ifr_name, name, sizeof(ifreq.ifr_name));
ifreq.ifr_flags = flags;
if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifreq) < 0)
err(1, "SIOCSIFFLAGS");
}
exit(0); exit(0);
} }
@ -857,18 +863,20 @@ setifflags(vname, value)
char *vname; char *vname;
int value; int value;
{ {
(void) strncpy(flagreq.ifr_name, name, sizeof (flagreq.ifr_name)); struct ifreq ifreq;
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&flagreq) < 0)
(void) strncpy(ifreq.ifr_name, name, sizeof(ifreq.ifr_name));
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifreq) < 0)
err(1, "SIOCGIFFLAGS"); err(1, "SIOCGIFFLAGS");
flags = flagreq.ifr_flags; flags = ifreq.ifr_flags;
if (value < 0) { if (value < 0) {
value = -value; value = -value;
flags &= ~value; flags &= ~value;
} else } else
flags |= value; flags |= value;
flagreq.ifr_flags = flags; ifreq.ifr_flags = flags;
if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&flagreq) < 0) if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifreq) < 0)
err(1, "SIOCSIFFLAGS"); err(1, "SIOCSIFFLAGS");
reset_if_flags = 1; reset_if_flags = 1;