diff --git a/common/device.c b/common/device.c index 0f72ce6..763aa27 100644 --- a/common/device.c +++ b/common/device.c @@ -1,4 +1,4 @@ -/* $NetBSD: device.c,v 1.3 1997/10/16 23:24:28 lukem Exp $ */ +/* $NetBSD: device.c,v 1.4 2002/07/13 11:35:35 itojun Exp $ */ /* * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: device.c,v 1.3 1997/10/16 23:24:28 lukem Exp $"); +__RCSID("$NetBSD: device.c,v 1.4 2002/07/13 11:35:35 itojun Exp $"); #endif #include "os.h" @@ -179,12 +179,12 @@ deviceInitOne(ifname) if ((strlen(dev) == 2) && (dev[0] == 'e') && ((dev[1] == 'n') || (dev[1] == 't'))) { - sprintf(interface,"ent%d\0",unit); + snprintf(interface, sizeof(interface), "ent%d\0", unit); } else { - sprintf(interface,"%s%d\0",dev,unit); + snprintf(interface, sizeof(interface), "%s%d\0", dev, unit); } #else - sprintf(interface,"%s",ifname); + snprintf(interface, sizeof(interface), "%s", ifname); #endif /* _AIX */ /* Ok, init it just once */ diff --git a/common/pf.c b/common/pf.c index cb0b6b7..8155239 100644 --- a/common/pf.c +++ b/common/pf.c @@ -1,4 +1,4 @@ -/* $NetBSD: pf.c,v 1.5 1998/05/24 20:30:55 thorpej Exp $ */ +/* $NetBSD: pf.c,v 1.6 2002/07/13 11:35:35 itojun Exp $ */ /* * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pf.c,v 1.5 1998/05/24 20:30:55 thorpej Exp $"); +__RCSID("$NetBSD: pf.c,v 1.6 2002/07/13 11:35:35 itojun Exp $"); #endif #include "os.h" @@ -99,7 +99,7 @@ pfInit(interface, mode, protocol, typ) /* Go through all the minors and find one that isn't in use. */ do { - (void) sprintf(device, "/dev/bpf%d", n++); + (void) snprintf(device, sizeof(device), "/dev/bpf%d", n++); fd = open(device, mode); } while (fd < 0 && errno == EBUSY); diff --git a/mopd/process.c b/mopd/process.c index 740c5bb..1214bf4 100644 --- a/mopd/process.c +++ b/mopd/process.c @@ -1,4 +1,4 @@ -/* $NetBSD: process.c,v 1.11 2002/02/18 22:00:37 thorpej Exp $ */ +/* $NetBSD: process.c,v 1.12 2002/07/13 11:35:35 itojun Exp $ */ /* * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: process.c,v 1.11 2002/02/18 22:00:37 thorpej Exp $"); +__RCSID("$NetBSD: process.c,v 1.12 2002/07/13 11:35:35 itojun Exp $"); #endif #include "os.h" @@ -364,7 +364,7 @@ mopNextLoad(dst, src, new_count, trans) close(dle->ldfd); dle->ldfd = -1; dle->status = DL_STATUS_FREE; - sprintf(line, + snprintf(line, sizeof(line), "%x:%x:%x:%x:%x:%x Load completed", dst[0],dst[1],dst[2],dst[3],dst[4],dst[5]); syslog(LOG_INFO, "%s", line); @@ -518,8 +518,9 @@ mopProcessDL(fd, ii, pkt, index, dst, src, trans, len) /* to ask. My solution is to use the ethernet addr */ /* as filename. Implementing a database would be */ /* overkill. */ - sprintf(pfile,"%02x%02x%02x%02x%02x%02x%c", - src[0],src[1],src[2],src[3],src[4],src[5],0); + snprintf(pfile, sizeof(pfile), + "%02x%02x%02x%02x%02x%02x%c", + src[0],src[1],src[2],src[3],src[4],src[5],0); } tmpc = mopGetChar(pkt,index); /* Processor */ @@ -531,17 +532,18 @@ mopProcessDL(fd, ii, pkt, index, dst, src, trans, len) memmove((char *)(dl_rpr->eaddr), (char *)src, 6); mopProcessInfo(pkt,index,moplen,dl_rpr,trans); - sprintf(filename,"%s/%s.SYS", MOP_FILE_PATH, pfile); + snprintf(filename, sizeof(filename), "%s/%s.SYS", + MOP_FILE_PATH, pfile); if ((mopCmpEAddr(dst,dl_mcst) == 0)) { if ((nfd = open(filename, O_RDONLY, 0)) != -1) { close(nfd); mopSendASV(src, ii->eaddr, ii, trans); - sprintf(line, + snprintf(line, sizeof(line), "%x:%x:%x:%x:%x:%x (%d) Do you have %s? (Yes)", src[0],src[1],src[2], src[3],src[4],src[5],trans,pfile); } else { - sprintf(line, + snprintf(line, sizeof(line), "%x:%x:%x:%x:%x:%x (%d) Do you have %s? (No)", src[0],src[1],src[2], src[3],src[4],src[5],trans,pfile); @@ -551,7 +553,7 @@ mopProcessDL(fd, ii, pkt, index, dst, src, trans, len) if ((mopCmpEAddr(dst,ii->eaddr) == 0)) { dl_rpr->ldfd = open(filename, O_RDONLY, 0); mopStartLoad(src, ii->eaddr, dl_rpr, trans); - sprintf(line, + snprintf(line, sizeof(line), "%x:%x:%x:%x:%x:%x Send me %s", src[0],src[1],src[2], src[3],src[4],src[5],pfile);