af_inet.c (298206) | af_inet.c (299873) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#ifndef lint 31static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#ifndef lint 31static const char rcsid[] = |
32 "$FreeBSD: head/sbin/ifconfig/af_inet.c 298206 2016-04-18 14:12:42Z araujo $"; | 32 "$FreeBSD: head/sbin/ifconfig/af_inet.c 299873 2016-05-16 00:25:24Z truckman $"; |
33#endif /* not lint */ 34 35#include <sys/param.h> 36#include <sys/ioctl.h> 37#include <sys/socket.h> 38#include <net/if.h> 39 40#include <ctype.h> --- 105 unchanged lines hidden (view full) --- 146in_status_tunnel(int s) 147{ 148 char src[NI_MAXHOST]; 149 char dst[NI_MAXHOST]; 150 struct ifreq ifr; 151 const struct sockaddr *sa = (const struct sockaddr *) &ifr.ifr_addr; 152 153 memset(&ifr, 0, sizeof(ifr)); | 33#endif /* not lint */ 34 35#include <sys/param.h> 36#include <sys/ioctl.h> 37#include <sys/socket.h> 38#include <net/if.h> 39 40#include <ctype.h> --- 105 unchanged lines hidden (view full) --- 146in_status_tunnel(int s) 147{ 148 char src[NI_MAXHOST]; 149 char dst[NI_MAXHOST]; 150 struct ifreq ifr; 151 const struct sockaddr *sa = (const struct sockaddr *) &ifr.ifr_addr; 152 153 memset(&ifr, 0, sizeof(ifr)); |
154 strncpy(ifr.ifr_name, name, IFNAMSIZ); | 154 strlcpy(ifr.ifr_name, name, IFNAMSIZ); |
155 156 if (ioctl(s, SIOCGIFPSRCADDR, (caddr_t)&ifr) < 0) 157 return; 158 if (sa->sa_family != AF_INET) 159 return; 160 if (getnameinfo(sa, sa->sa_len, src, sizeof(src), 0, 0, NI_NUMERICHOST) != 0) 161 src[0] = '\0'; 162 --- 8 unchanged lines hidden (view full) --- 171} 172 173static void 174in_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) 175{ 176 struct in_aliasreq addreq; 177 178 memset(&addreq, 0, sizeof(addreq)); | 155 156 if (ioctl(s, SIOCGIFPSRCADDR, (caddr_t)&ifr) < 0) 157 return; 158 if (sa->sa_family != AF_INET) 159 return; 160 if (getnameinfo(sa, sa->sa_len, src, sizeof(src), 0, 0, NI_NUMERICHOST) != 0) 161 src[0] = '\0'; 162 --- 8 unchanged lines hidden (view full) --- 171} 172 173static void 174in_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) 175{ 176 struct in_aliasreq addreq; 177 178 memset(&addreq, 0, sizeof(addreq)); |
179 strncpy(addreq.ifra_name, name, IFNAMSIZ); | 179 strlcpy(addreq.ifra_name, name, IFNAMSIZ); |
180 memcpy(&addreq.ifra_addr, srcres->ai_addr, srcres->ai_addr->sa_len); 181 memcpy(&addreq.ifra_dstaddr, dstres->ai_addr, dstres->ai_addr->sa_len); 182 183 if (ioctl(s, SIOCSIFPHYADDR, &addreq) < 0) 184 warn("SIOCSIFPHYADDR"); 185} 186 187static struct afswtch af_inet = { --- 22 unchanged lines hidden --- | 180 memcpy(&addreq.ifra_addr, srcres->ai_addr, srcres->ai_addr->sa_len); 181 memcpy(&addreq.ifra_dstaddr, dstres->ai_addr, dstres->ai_addr->sa_len); 182 183 if (ioctl(s, SIOCSIFPHYADDR, &addreq) < 0) 184 warn("SIOCSIFPHYADDR"); 185} 186 187static struct afswtch af_inet = { --- 22 unchanged lines hidden --- |