use bounded string op

This commit is contained in:
itojun 2003-07-14 08:36:34 +00:00
parent 7b8c272d80
commit 47a6a58fe5
2 changed files with 10 additions and 9 deletions

View File

@ -1,8 +1,8 @@
/* $NetBSD: getether.c,v 1.6 2002/07/14 00:30:02 wiz Exp $ */
/* $NetBSD: getether.c,v 1.7 2003/07/14 08:36:34 itojun Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: getether.c,v 1.6 2002/07/14 00:30:02 wiz Exp $");
__RCSID("$NetBSD: getether.c,v 1.7 2003/07/14 08:36:34 itojun Exp $");
#endif
/*
@ -47,8 +47,9 @@ getether(char *ifname, char *eap)
int rc = -1;
int fd;
struct ifdevea phys;
bzero(&phys, sizeof(phys));
strcpy(phys.ifr_name, ifname);
strncpy(phys.ifr_name, ifname, sizeof(phys.ifr_name));
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
report(LOG_ERR, "getether: socket(INET,DGRAM) failed");
return -1;
@ -197,7 +198,7 @@ getether(char *ifname, char *eap)
char *enaddr;
int unit = -1; /* which unit to attach */
sprintf(devname, "/dev/%s", ifname);
snprintf(devname, sizeof(devname), "/dev/%s", ifname);
fd = open(devname, 2);
if (fd < 0) {
/* Try without the trailing digit. */
@ -342,8 +343,9 @@ getether(char *ifname, char *eap)
int rc = -1;
int fd;
struct ifreq phys;
bzero(&phys, sizeof(phys));
strcpy(phys.ifr_name, ifname);
strncpy(phys.ifr_name, ifname, sizeof(phys.ifr_name));
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
report(LOG_ERR, "getether: socket(INET,DGRAM) failed");
return -1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: device.c,v 1.6 2003/04/20 00:17:22 christos Exp $ */
/* $NetBSD: device.c,v 1.7 2003/07/14 08:37:53 itojun Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: device.c,v 1.6 2003/04/20 00:17:22 christos Exp $");
__RCSID("$NetBSD: device.c,v 1.7 2003/07/14 08:37:53 itojun Exp $");
#endif
#include "os.h"
@ -118,7 +118,6 @@ deviceOpen(ifname, proto, trans)
}
if (tmp.fd != -1) {
p = (struct if_info *)malloc(sizeof(*p));
if (p == 0)
mopLogErr("deviceOpen: malloc");
@ -126,7 +125,7 @@ deviceOpen(ifname, proto, trans)
p->next = iflist;
iflist = p;
strcpy(p->if_name,tmp.if_name);
strlcpy(p->if_name, tmp.if_name, sizeof(p->if_name));
p->iopen = tmp.iopen;
p->write = pfWrite;
p->read = tmp.read;