diff options
| author | itojun <itojun@NetBSD.org> | 2004-04-22 00:17:10 +0000 |
|---|---|---|
| committer | itojun <itojun@NetBSD.org> | 2004-04-22 00:17:10 +0000 |
| commit | aca4c091d32e5d41fde26cf072df6355ec7fa79b (patch) | |
| tree | 498f57df69e0a3d0b702d3aa166ed352fe32e53f /sys/dev | |
| parent | fd2a977729985cfb18c9fefeca871d3649724943 (diff) | |
sprintf -> snprintf
Diffstat (limited to 'sys/dev')
58 files changed, 413 insertions, 361 deletions
diff --git a/sys/dev/acpi/acpi_ec.c b/sys/dev/acpi/acpi_ec.c index a330279710c..b56d8d14bf7 100644 --- a/sys/dev/acpi/acpi_ec.c +++ b/sys/dev/acpi/acpi_ec.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_ec.c,v 1.28 2004/04/11 15:41:50 kochi Exp $ */ +/* $NetBSD: acpi_ec.c,v 1.29 2004/04/22 00:17:10 itojun Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -172,7 +172,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.28 2004/04/11 15:41:50 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.29 2004/04/22 00:17:10 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -661,7 +661,7 @@ EcGpeQueryHandler(void *Context) /* * Evaluate _Qxx to respond to the controller. */ - sprintf(qxx, "_Q%02X", Data); + snprintf(qxx, sizeof(qxx), "_Q%02X", Data); rv = AcpiEvaluateObject(sc->sc_handle, qxx, NULL, NULL); diff --git a/sys/dev/ata/ld_ataraid.c b/sys/dev/ata/ld_ataraid.c index daf79f16b3a..0badc933a53 100644 --- a/sys/dev/ata/ld_ataraid.c +++ b/sys/dev/ata/ld_ataraid.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld_ataraid.c,v 1.10 2004/01/25 18:06:48 hannken Exp $ */ +/* $NetBSD: ld_ataraid.c,v 1.11 2004/04/22 00:17:10 itojun Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.10 2004/01/25 18:06:48 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.11 2004/04/22 00:17:10 itojun Exp $"); #include "rnd.h" @@ -161,7 +161,8 @@ ld_ataraid_attach(struct device *parent, struct device *self, void *aux) break; default: - sprintf(unklev, "<unknown level 0x%x>", aai->aai_level); + snprintf(unklev, sizeof(unklev), "<unknown level 0x%x>", + aai->aai_level); level = unklev; } diff --git a/sys/dev/cardbus/ehci_cardbus.c b/sys/dev/cardbus/ehci_cardbus.c index 2d10e56beb6..150276004b6 100644 --- a/sys/dev/cardbus/ehci_cardbus.c +++ b/sys/dev/cardbus/ehci_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: ehci_cardbus.c,v 1.6 2002/10/02 16:33:41 thorpej Exp $ */ +/* $NetBSD: ehci_cardbus.c,v 1.7 2004/04/22 00:17:10 itojun Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci_cardbus.c,v 1.6 2002/10/02 16:33:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci_cardbus.c,v 1.7 2004/04/22 00:17:10 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -171,11 +171,10 @@ XXX (ct->ct_cf->cardbus_mem_open)(cc, 0, iob, iob + 0x40); vendor = cardbus_findvendor(ca->ca_id); sc->sc.sc_id_vendor = CARDBUS_VENDOR(ca->ca_id); if (vendor) - strncpy(sc->sc.sc_vendor, vendor, - sizeof(sc->sc.sc_vendor) - 1); + strlcpy(sc->sc.sc_vendor, vendor, sizeof(sc->sc.sc_vendor)); else - sprintf(sc->sc.sc_vendor, "vendor 0x%04x", - CARDBUS_VENDOR(ca->ca_id)); + snprintf(sc->sc.sc_vendor, sizeof(sc->sc.sc_vendor), + "vendor 0x%04x", CARDBUS_VENDOR(ca->ca_id)); /* * Find companion controllers. According to the spec they always diff --git a/sys/dev/cardbus/ohci_cardbus.c b/sys/dev/cardbus/ohci_cardbus.c index 7d70a0b7174..c21a7be17be 100644 --- a/sys/dev/cardbus/ohci_cardbus.c +++ b/sys/dev/cardbus/ohci_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: ohci_cardbus.c,v 1.15 2003/03/11 11:59:31 drochner Exp $ */ +/* $NetBSD: ohci_cardbus.c,v 1.16 2004/04/22 00:17:10 itojun Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ohci_cardbus.c,v 1.15 2003/03/11 11:59:31 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci_cardbus.c,v 1.16 2004/04/22 00:17:10 itojun Exp $"); #include "ehci_cardbus.h" @@ -170,11 +170,10 @@ XXX (ct->ct_cf->cardbus_mem_open)(cc, 0, iob, iob + 0x40); vendor = cardbus_findvendor(ca->ca_id); sc->sc.sc_id_vendor = CARDBUS_VENDOR(ca->ca_id); if (vendor) - strncpy(sc->sc.sc_vendor, vendor, - sizeof(sc->sc.sc_vendor) - 1); + strlcpy(sc->sc.sc_vendor, vendor, sizeof(sc->sc.sc_vendor)); else - sprintf(sc->sc.sc_vendor, "vendor 0x%04x", - CARDBUS_VENDOR(ca->ca_id)); + snprintf(sc->sc.sc_vendor, sizeof(sc->sc.sc_vendor), + "vendor 0x%04x", CARDBUS_VENDOR(ca->ca_id)); r = ohci_init(&sc->sc); if (r != USBD_NORMAL_COMPLETION) { diff --git a/sys/dev/eisa/eisa.c b/sys/dev/eisa/eisa.c index 0aa049b55c5..7a7b654fbd1 100644 --- a/sys/dev/eisa/eisa.c +++ b/sys/dev/eisa/eisa.c @@ -1,4 +1,4 @@ -/* $NetBSD: eisa.c,v 1.31 2003/01/01 00:10:17 thorpej Exp $ */ +/* $NetBSD: eisa.c,v 1.32 2004/04/22 00:17:10 itojun Exp $ */ /* * Copyright (c) 1995, 1996 Christopher G. Demetriou @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: eisa.c,v 1.31 2003/01/01 00:10:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: eisa.c,v 1.32 2004/04/22 00:17:10 itojun Exp $"); #include "opt_eisaverbose.h" @@ -61,7 +61,7 @@ CFATTACH_DECL(eisa, sizeof(struct device), int eisasubmatch(struct device *, struct cfdata *, void *); int eisaprint(void *, const char *); -void eisa_devinfo(const char *, char *); +void eisa_devinfo(const char *, char *, size_t); int eisamatch(struct device *parent, struct cfdata *cf, void *aux) @@ -83,7 +83,7 @@ eisaprint(void *aux, const char *pnp) char devinfo[256]; if (pnp) { - eisa_devinfo(ea->ea_idstring, devinfo); + eisa_devinfo(ea->ea_idstring, devinfo, sizeof(devinfo)); aprint_normal("%s at %s", devinfo, pnp); } aprint_normal(" slot %d", ea->ea_slot); @@ -211,7 +211,7 @@ struct eisa_knowndev { #endif /* EISAVEBSOSE */ void -eisa_devinfo(const char *id, char *cp) +eisa_devinfo(const char *id, char *cp, size_t l) { #ifdef EISAVERBOSE const char *name; @@ -235,13 +235,13 @@ eisa_devinfo(const char *id, char *cp) } if (name == NULL) - sprintf(cp, "unknown device %s", id); + snprintf(cp, l, "unknown device %s", id); else if (onlyvendor) - sprintf(cp, "unknown %s device %s", name, id); + snprintf(cp, l, "unknown %s device %s", name, id); else - sprintf(cp, "%s", name); + snprintf(cp, l, "%s", name); #else /* EISAVERBOSE */ - sprintf(cp, "device %s", id); + snprintf(cp, l, "device %s", id); #endif /* EISAVERBOSE */ } diff --git a/sys/dev/i2o/dpti.c b/sys/dev/i2o/dpti.c index 0cdd9c5e22c..73d6d4b5f2b 100644 --- a/sys/dev/i2o/dpti.c +++ b/sys/dev/i2o/dpti.c @@ -1,4 +1,4 @@ -/* $NetBSD: dpti.c,v 1.17 2003/12/09 19:51:23 ad Exp $ */ +/* $NetBSD: dpti.c,v 1.18 2004/04/22 00:17:10 itojun Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dpti.c,v 1.17 2003/12/09 19:51:23 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dpti.c,v 1.18 2004/04/22 00:17:10 itojun Exp $"); #include "opt_i2o.h" @@ -193,7 +193,8 @@ dpti_attach(struct device *parent, struct device *self, void *aux) * must be no more than 46 bytes long (see dptivar.h). */ printf(": DPT/Adaptec RAID management interface\n"); - sprintf(dpti_sig.dsDescription, "NetBSD %s I2O OSM", osrelease); + snprintf(dpti_sig.dsDescription, sizeof(dpti_sig.dsDescription), + "NetBSD %s I2O OSM", osrelease); rv = iop_field_get_all(iop, I2O_TID_IOP, I2O_DPT_PARAM_EXEC_IOP_BUFFERS, ¶m, diff --git a/sys/dev/i2o/iop.c b/sys/dev/i2o/iop.c index b052b8bf89b..267a06aa9f8 100644 --- a/sys/dev/i2o/iop.c +++ b/sys/dev/i2o/iop.c @@ -1,4 +1,4 @@ -/* $NetBSD: iop.c,v 1.42 2003/12/09 19:43:54 ad Exp $ */ +/* $NetBSD: iop.c,v 1.43 2004/04/22 00:17:10 itojun Exp $ */ /*- * Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: iop.c,v 1.42 2003/12/09 19:43:54 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iop.c,v 1.43 2004/04/22 00:17:10 itojun Exp $"); #include "opt_i2o.h" #include "iop.h" @@ -223,7 +223,7 @@ static inline void iop_outl_msg(struct iop_softc *, int, u_int32_t); static void iop_config_interrupts(struct device *); static void iop_configure_devices(struct iop_softc *, int, int); -static void iop_devinfo(int, char *); +static void iop_devinfo(int, char *, size_t); static int iop_print(void *, const char *); static void iop_shutdown(void *); static int iop_submatch(struct device *, struct cfdata *, void *); @@ -854,7 +854,7 @@ iop_adjqparam(struct iop_softc *sc, int mpi) } static void -iop_devinfo(int class, char *devinfo) +iop_devinfo(int class, char *devinfo, size_t l) { #ifdef I2OVERBOSE int i; @@ -864,12 +864,12 @@ iop_devinfo(int class, char *devinfo) break; if (i == sizeof(iop_class) / sizeof(iop_class[0])) - sprintf(devinfo, "device (class 0x%x)", class); + snprintf(devinfo, l, "device (class 0x%x)", class); else - strcpy(devinfo, iop_class[i].ic_caption); + strlcpy(devinfo, iop_class[i].ic_caption, l); #else - sprintf(devinfo, "device (class 0x%x)", class); + snprintf(devinfo, l, "device (class 0x%x)", class); #endif } @@ -882,7 +882,7 @@ iop_print(void *aux, const char *pnp) ia = aux; if (pnp != NULL) { - iop_devinfo(ia->ia_class, devinfo); + iop_devinfo(ia->ia_class, devinfo, sizeof(devinfo)); aprint_normal("%s at %s", devinfo, pnp); } aprint_normal(" tid %d", ia->ia_tid); diff --git a/sys/dev/i2o/iopl.c b/sys/dev/i2o/iopl.c index f19a15c43fd..b75cb810291 100644 --- a/sys/dev/i2o/iopl.c +++ b/sys/dev/i2o/iopl.c @@ -1,4 +1,4 @@ -/* $NetBSD: iopl.c,v 1.11 2002/10/02 16:33:51 thorpej Exp $ */ +/* $NetBSD: iopl.c,v 1.12 2004/04/22 00:17:11 itojun Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -46,7 +46,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: iopl.c,v 1.11 2002/10/02 16:33:51 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iopl.c,v 1.12 2004/04/22 00:17:11 itojun Exp $"); #include "opt_i2o.h" #include "opt_inet.h" @@ -277,7 +277,7 @@ iopl_attach(struct device *parent, struct device *self, void *aux) case I2O_LAN_TYPE_FIBRECHANNEL: typestr = "fibre channel"; addrstr = wwn; - sprintf(wwn, "%08x%08x", + snprintf(wwn, sizeof(wwn), "%08x%08x", ((u_int32_t *)param.p.ldi.hwaddr)[0], ((u_int32_t *)param.p.ldi.hwaddr)[1]); iff = IFF_BROADCAST | IFF_MULTICAST; diff --git a/sys/dev/ic/bha.c b/sys/dev/ic/bha.c index 00267ff205d..388ca744fed 100644 --- a/sys/dev/ic/bha.c +++ b/sys/dev/ic/bha.c @@ -1,4 +1,4 @@ -/* $NetBSD: bha.c,v 1.57 2003/11/02 11:07:45 wiz Exp $ */ +/* $NetBSD: bha.c,v 1.58 2004/04/22 00:17:11 itojun Exp $ */ /*- * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bha.c,v 1.57 2003/11/02 11:07:45 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bha.c,v 1.58 2004/04/22 00:17:11 itojun Exp $"); #include "opt_ddb.h" @@ -1199,15 +1199,15 @@ bha_info(sc) */ if (inquire.reply.bus_type == BHA_BUS_TYPE_24BIT && sc->sc_firmware[0] < '3') - sprintf(sc->sc_model, "542B"); + snprintf(sc->sc_model, sizeof(sc->sc_model), "542B"); else if (inquire.reply.bus_type == BHA_BUS_TYPE_32BIT && sc->sc_firmware[0] == '2' && (sc->sc_firmware[2] == '1' || (sc->sc_firmware[2] == '2' && sc->sc_firmware[3] == '0'))) - sprintf(sc->sc_model, "742A"); + snprintf(sc->sc_model, sizeof(sc->sc_model), "742A"); else if (inquire.reply.bus_type == BHA_BUS_TYPE_32BIT && sc->sc_firmware[0] == '0') - sprintf(sc->sc_model, "747A"); + snprintf(sc->sc_model, sizeof(sc->sc_model), "747A"); else { p = sc->sc_model; model.cmd.opcode = BHA_INQUIRE_MODEL; diff --git a/sys/dev/ic/cs4231.c b/sys/dev/ic/cs4231.c index b978c2226a6..49417a6eefc 100644 --- a/sys/dev/ic/cs4231.c +++ b/sys/dev/ic/cs4231.c @@ -1,4 +1,4 @@ -/* $NetBSD: cs4231.c,v 1.13 2003/09/10 11:53:53 uwe Exp $ */ +/* $NetBSD: cs4231.c,v 1.14 2004/04/22 00:17:11 itojun Exp $ */ /*- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cs4231.c,v 1.13 2003/09/10 11:53:53 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cs4231.c,v 1.14 2004/04/22 00:17:11 itojun Exp $"); #include "audio.h" #if NAUDIO > 0 @@ -171,7 +171,8 @@ cs4231_common_attach(sc, ioh) break; default: if ((buf = malloc(32, M_TEMP, M_NOWAIT)) != NULL) { - sprintf(buf, "unknown rev: %x/%x", reg&0xe0, reg&7); + snprintf(buf, 32, "unknown rev: %x/%x", + reg&0xe0, reg&7); sc->sc_ad1848.chip_name = buf; } } diff --git a/sys/dev/ic/daic.c b/sys/dev/ic/daic.c index 8406410b68e..b8616fbb599 100644 --- a/sys/dev/ic/daic.c +++ b/sys/dev/ic/daic.c @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: daic.c,v 1.18 2004/02/24 15:22:01 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: daic.c,v 1.19 2004/04/22 00:17:11 itojun Exp $"); /* * daic.c: MI driver for Diehl active ISDN cards (S, SX, SXn, SCOM, QUADRO) @@ -696,10 +696,12 @@ daic_register_port(struct daic_softc *sc, int port) /* make sure this hardware driver type is known to layer 4 */ if (sc->sc_cardtype == DAIC_TYPE_QUAD) - sprintf(devname, "%s port %d", sc->sc_dev.dv_xname, port); + snprintf(devname, sizeof(devname), "%s port %d", + sc->sc_dev.dv_xname, port); else - strcpy(devname, sc->sc_dev.dv_xname); - sprintf(cardname, "EICON.Diehl %s", cardtypename(sc->sc_cardtype)); + strlcpy(devname, sc->sc_dev.dv_xname, sizeof(devname)); + snprintf(cardname, sizeof(cardname), "EICON.Diehl %s", + cardtypename(sc->sc_cardtype)); l3drv = isdn_attach_isdnif( devname, cardname, &sc->sc_port[port], &daic_l3_functions, 2); sc->sc_port[port].du_l3 = l3drv; diff --git a/sys/dev/ic/dpt.c b/sys/dev/ic/dpt.c index 047d14d19cd..fde77e18a33 100644 --- a/sys/dev/ic/dpt.c +++ b/sys/dev/ic/dpt.c @@ -1,4 +1,4 @@ -/* $NetBSD: dpt.c,v 1.42 2003/10/25 18:35:42 christos Exp $ */ +/* $NetBSD: dpt.c,v 1.43 2004/04/22 00:17:11 itojun Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.42 2003/10/25 18:35:42 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.43 2004/04/22 00:17:11 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -333,7 +333,8 @@ dpt_init(struct dpt_softc *sc, const char *intrstr) char model[16]; ec = &sc->sc_ec; - sprintf(dpt_sig.dsDescription, "NetBSD %s DPT driver", osrelease); + snprintf(dpt_sig.dsDescription, sizeof(dpt_sig.dsDescription), + "NetBSD %s DPT driver", osrelease); /* * Allocate the CCB/status packet/scratch DMA map and load. diff --git a/sys/dev/ic/hd64570.c b/sys/dev/ic/hd64570.c index 46fd8085f3a..971a5761d18 100644 --- a/sys/dev/ic/hd64570.c +++ b/sys/dev/ic/hd64570.c @@ -1,4 +1,4 @@ -/* $NetBSD: hd64570.c,v 1.26 2004/02/24 15:05:54 wiz Exp $ */ +/* $NetBSD: hd64570.c,v 1.27 2004/04/22 00:17:11 itojun Exp $ */ /* * Copyright (c) 1999 Christian E. Hopps @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hd64570.c,v 1.26 2004/02/24 15:05:54 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hd64570.c,v 1.27 2004/04/22 00:17:11 itojun Exp $"); #include "bpfilter.h" #include "opt_inet.h" @@ -444,7 +444,7 @@ sca_port_attach(struct sca_softc *sc, u_int port) * attach to the network layer */ ifp = &scp->sp_if; - sprintf(ifp->if_xname, "ntwo%d", ntwo_unit); + snprintf(ifp->if_xname, sizeof(ifp->if_xname), "ntwo%d", ntwo_unit); ifp->if_softc = scp; ifp->if_mtu = SCA_MTU; ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; diff --git a/sys/dev/ic/interwave.c b/sys/dev/ic/interwave.c index c1e6b1c56c7..59e47c3b4b6 100644 --- a/sys/dev/ic/interwave.c +++ b/sys/dev/ic/interwave.c @@ -1,4 +1,4 @@ -/* $NetBSD: interwave.c,v 1.19 2003/10/30 01:58:17 simonb Exp $ */ +/* $NetBSD: interwave.c,v 1.20 2004/04/22 00:17:11 itojun Exp $ */ /* * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.19 2003/10/30 01:58:17 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.20 2004/04/22 00:17:11 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -486,7 +486,8 @@ iwreset(sc, warm) sc->vers = reg >> 4; if (!warm) - sprintf(iw_device.version, "%d.%d", sc->vers, sc->revision); + snprintf(iw_device.version, sizeof(iw_device.version), "%d.%d", + sc->vers, sc->revision); IW_WRITE_GENERAL_1(IDECI, 0x7f); /* irqs and codec decode * enable */ diff --git a/sys/dev/ic/midway.c b/sys/dev/ic/midway.c index 3c61bc3763e..bd730c67e3f 100644 --- a/sys/dev/ic/midway.c +++ b/sys/dev/ic/midway.c @@ -1,4 +1,4 @@ -/* $NetBSD: midway.c,v 1.63 2003/11/02 11:07:45 wiz Exp $ */ +/* $NetBSD: midway.c,v 1.64 2004/04/22 00:17:11 itojun Exp $ */ /* (sync'd to midway.c 1.68) */ /* @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: midway.c,v 1.63 2003/11/02 11:07:45 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: midway.c,v 1.64 2004/04/22 00:17:11 itojun Exp $"); #include "opt_natm.h" @@ -1293,9 +1293,10 @@ caddr_t data; case SIOCGPVCSIF: if (ifp != &sc->enif) { #ifdef __NetBSD__ - strcpy(ifr->ifr_name, sc->enif.if_xname); + strlcpy(ifr->ifr_name, sc->enif.if_xname, + sizeof(ifr->ifr_name)); #else - sprintf(ifr->ifr_name, "%s%d", + snprintf(ifr->ifr_name, sizeof(ifr->ifr_name), "%s%d", sc->enif.if_name, sc->enif.if_unit); #endif } @@ -1312,10 +1313,11 @@ caddr_t data; if ((sifp = en_pvcattach(ifp)) != NULL) { #ifdef __NetBSD__ - strcpy(ifr->ifr_name, sifp->if_xname); + strlcpy(ifr->ifr_name, sifp->if_xname, + sizeof(ifr->ifr_name)); #else - sprintf(ifr->ifr_name, "%s%d", - sifp->if_name, sifp->if_unit); + snprintf(ifr->ifr_name, sizeof(ifr->ifr_name), "%s%d", + sifp->if_name, sifp->if_unit); #endif #if defined(__KAME__) && defined(INET6) /* get EUI64 for PVC, from ATM hardware interface */ @@ -3932,10 +3934,11 @@ static int en_pvctx(sc, pvcreq) struct pvcsif *pvcsif = (struct pvcsif *)ifp; #ifdef __NetBSD__ - strcpy(pvcreq->pvc_ifname, sc->enif.if_xname); + strlcpy(pvcreq->pvc_ifname, sc->enif.if_xname, + sizeof(pvcreq->pvc_ifname)); #else - sprintf(pvcreq->pvc_ifname, "%s%d", - sc->enif.if_name, sc->enif.if_unit); + snprintf(pvcreq->pvc_ifname, sizeof(pvcreq->pvc_ifname), "%s%d", + sc->enif.if_name, sc->enif.if_unit); #endif ATM_PH_FLAGS(&api.aph) = (ATM_PH_FLAGS(pvc_aph) & (ATM_PH_AAL5|ATM_PH_LLCSNAP)); @@ -3996,10 +3999,11 @@ static int en_pvctxget(sc, pvcreq) else { /* pvc subinterface */ #ifdef __NetBSD__ - strcpy(pvcreq->pvc_ifname, sc->enif.if_xname); + strlcpy(pvcreq->pvc_ifname, sc->enif.if_xname, + sizeof(pvcreq->pvc_ifname)); #else - sprintf(pvcreq->pvc_ifname, "%s%d", - sc->enif.if_name, sc->enif.if_unit); + snprintf(pvcreq->pvc_ifname, sizeof(pvcreq->pvc_ifname), "%s%d", + sc->enif.if_name, sc->enif.if_unit); #endif pvcsif = (struct pvcsif *)ifp; diff --git a/sys/dev/ic/mlx.c b/sys/dev/ic/mlx.c index 8f75632abec..55bcf0b7a10 100644 --- a/sys/dev/ic/mlx.c +++ b/sys/dev/ic/mlx.c @@ -1,4 +1,4 @@ -/* $NetBSD: mlx.c,v 1.28 2003/06/29 22:30:13 fvdl Exp $ */ +/* $NetBSD: mlx.c,v 1.29 2004/04/22 00:17:11 itojun Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.28 2003/06/29 22:30:13 fvdl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.29 2004/04/22 00:17:11 itojun Exp $"); #include "ld.h" @@ -546,7 +546,7 @@ mlx_describe(struct mlx_softc *mlx) } if (model == NULL) { - sprintf(buf, " model 0x%x", ci->ci_hardware_id); + snprintf(buf, sizeof(buf), " model 0x%x", ci->ci_hardware_id); model = buf; } @@ -2129,12 +2129,12 @@ mlx_ccb_diagnose(struct mlx_ccb *mc) if ((mc->mc_mbox[0] == mlx_msgs[i].command || mlx_msgs[i].command == 0) && mc->mc_status == mlx_msgs[i].status) { - sprintf(buf, "%s (0x%x)", + snprintf(buf, sizeof(buf), "%s (0x%x)", mlx_status_msgs[mlx_msgs[i].msg], mc->mc_status); return (buf); } - sprintf(buf, "unknown response 0x%x for command 0x%x", + snprintf(buf, sizeof(buf), "unknown response 0x%x for command 0x%x", (int)mc->mc_status, (int)mc->mc_mbox[0]); return (buf); diff --git a/sys/dev/ic/nslm7x.c b/sys/dev/ic/nslm7x.c index e9f4de35ec8..8524fdd7343 100644 --- a/sys/dev/ic/nslm7x.c +++ b/sys/dev/ic/nslm7x.c @@ -1,4 +1,4 @@ -/* $NetBSD: nslm7x.c,v 1.17 2002/11/15 14:55:41 ad Exp $ */ +/* $NetBSD: nslm7x.c,v 1.18 2004/04/22 00:17:11 itojun Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.17 2002/11/15 14:55:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.18 2004/04/22 00:17:11 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -271,7 +271,8 @@ lm_common_match(sc) for (i = 0; i < 7; ++i) { sc->sensors[i].units = sc->info[i].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[i].desc, "IN %d", i); + snprintf(sc->info[i].desc, sizeof(sc->info[i].desc), + "IN %d", i); } /* default correction factors for resistors on higher voltage inputs */ @@ -314,7 +315,8 @@ wb_match(sc) for (i = 0; i < 7; ++i) { sc->sensors[i].units = sc->info[i].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[i].desc, "IN %d", i); + snprintf(sc->info[i].desc, sizeof(sc->info[i].desc), + "IN %d", i); } /* default correction factors for higher voltage inputs */ @@ -368,31 +370,31 @@ wb_setup_volt(sc) struct lm_softc *sc; { sc->sensors[0].units = sc->info[0].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[0].desc, "VCORE A"); + snprintf(sc->info[0].desc, sizeof(sc->info[0].desc), "VCORE A"); sc->info[0].rfact = 10000; sc->sensors[1].units = sc->info[1].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[1].desc, "VCORE B"); + snprintf(sc->info[1].desc, sizeof(sc->info[1].desc), "VCORE B"); sc->info[1].rfact = 10000; sc->sensors[2].units = sc->info[2].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[2].desc, "+3.3V"); + snprintf(sc->info[2].desc, sizeof(sc->info[2].desc), "+3.3V"); sc->info[2].rfact = 10000; sc->sensors[3].units = sc->info[3].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[3].desc, "+5V"); + snprintf(sc->info[3].desc, sizeof(sc->info[3].desc), "+5V"); sc->info[3].rfact = 16778; sc->sensors[4].units = sc->info[4].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[4].desc, "+12V"); + snprintf(sc->info[4].desc, sizeof(sc->info[4].desc), "+12V"); sc->info[4].rfact = 38000; sc->sensors[5].units = sc->info[5].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[5].desc, "-12V"); + snprintf(sc->info[5].desc, sizeof(sc->info[5].desc), "-12V"); sc->info[5].rfact = 10000; sc->sensors[6].units = sc->info[6].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[6].desc, "-5V"); + snprintf(sc->info[6].desc, sizeof(sc->info[6].desc), "-5V"); sc->info[6].rfact = 10000; sc->sensors[7].units = sc->info[7].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[7].desc, "+5VSB"); + snprintf(sc->info[7].desc, sizeof(sc->info[7].desc), "+5VSB"); sc->info[7].rfact = 15151; sc->sensors[8].units = sc->info[8].units = ENVSYS_SVOLTS_DC; - sprintf(sc->info[8].desc, "VBAT"); + snprintf(sc->info[8].desc, sizeof(sc->info[8].desc), "VBAT"); sc->info[8].rfact = 10000; } @@ -405,7 +407,8 @@ setup_temp(sc, start, n) for (i = 0; i < n; i++) { sc->sensors[start + i].units = ENVSYS_STEMP; - sprintf(sc->info[start + i].desc, "Temp %d", i + 1); + snprintf(sc->info[start + i].desc, + sizeof(sc->info[start + i].desc), "Temp %d", i + 1); } } @@ -419,7 +422,8 @@ setup_fan(sc, start, n) for (i = 0; i < n; ++i) { sc->sensors[start + i].units = ENVSYS_SFANRPM; sc->info[start + i].units = ENVSYS_SFANRPM; - sprintf(sc->info[start + i].desc, "Fan %d", i + 1); + snprintf(sc->info[start + i].desc, + sizeof(sc->info[start + i].desc), "Fan %d", i + 1); } } diff --git a/sys/dev/ic/opl.c b/sys/dev/ic/opl.c index b1235cd5ffd..c4f44d3f3c2 100644 --- a/sys/dev/ic/opl.c +++ b/sys/dev/ic/opl.c @@ -1,4 +1,4 @@ -/* $NetBSD: opl.c,v 1.20 2003/12/04 13:57:30 keihan Exp $ */ +/* $NetBSD: opl.c,v 1.21 2004/04/22 00:17:11 itojun Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: opl.c,v 1.20 2003/12/04 13:57:30 keihan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: opl.c,v 1.21 2004/04/22 00:17:11 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -158,7 +158,8 @@ opl_attach(sc) } sc->syn.mets = &opl3_midi; - sprintf(sc->syn.name, "%sYamaha OPL%d", sc->syn.name, sc->model); + snprintf(sc->syn.name, sizeof(sc->syn.name), "%sYamaha OPL%d", + sc->syn.name, sc->model); sc->syn.data = sc; sc->syn.nvoice = sc->model == OPL_2 ? OPL2_NVOICE : OPL3_NVOICE; sc->syn.flags = MS_DOALLOC | MS_FREQXLATE; diff --git a/sys/dev/ic/rrunner.c b/sys/dev/ic/rrunner.c index d71f2680beb..ad411e668da 100644 --- a/sys/dev/ic/rrunner.c +++ b/sys/dev/ic/rrunner.c @@ -1,4 +1,4 @@ -/* $NetBSD: rrunner.c,v 1.44 2003/11/03 03:05:25 ichiro Exp $ */ +/* $NetBSD: rrunner.c,v 1.45 2004/04/22 00:17:11 itojun Exp $ */ /* * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rrunner.c,v 1.44 2003/11/03 03:05:25 ichiro Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rrunner.c,v 1.45 2004/04/22 00:17:11 itojun Exp $"); #include "opt_inet.h" #include "opt_ns.h" @@ -1469,7 +1469,7 @@ eshintr(arg) int i; buf[0] = '\0'; - strcat(buf, "rc: "); + strlcat(buf, "rc: ", sizeof(buf)); rc_send_consumer = (rc_offsets >> 8) & 0xff; rc_snap_ring_consumer = (rc_offsets >> 16) & 0xff; for (i = 0; i < RR_MAX_RECV_RING; i += 4) { @@ -1479,8 +1479,8 @@ eshintr(arg) /* XXX: should do this right! */ NTOHL(rc_offsets); *((u_int32_t *) &fp_ring_consumer[i]) = rc_offsets; - sprintf(t, "%.8x|", rc_offsets); - strcat(buf, t); + snprintf(t, sizeof(t), "%.8x|", rc_offsets); + strlcat(buf, t, sizeof(buf)); } } start_consumer = sc->sc_event_consumer; @@ -1887,12 +1887,12 @@ eshintr(arg) u_int32_t u; buf[0] = '\0'; - strcat(buf, "drv: "); + strlcat(buf, "drv: ", sizeof(buf)); for (i = 0; i < RR_MAX_RECV_RING; i += 4) { /* XXX: should do this right! */ u = *((u_int32_t *) &fp_ring_consumer[i]); - sprintf(t, "%.8x|", u); - strcat(buf, t); + snprintf(t, sizeof(t), "%.8x|", u); + strlcat(buf, t, sizeof(buf)); NTOHL(u); bus_space_write_4(iot, ioh, RR_DRIVER_RECV_CONS + i, u); @@ -1903,14 +1903,14 @@ eshintr(arg) #endif buf[0] = '\0'; - strcat(buf, "rcn: "); + strlcat(buf, "rcn: ", sizeof(buf)); for (i = 0; i < RR_MAX_RECV_RING; i += 4) { u = bus_space_read_4(iot, ioh, RR_RUNCODE_RECV_CONS + i); /* XXX: should do this right! */ NTOHL(u); - sprintf(t, "%.8x|", u); - strcat(buf, t); + snprintf(t, sizeof(t), "%.8x|", u); + strlcat(buf, t, sizeof(buf)); } #ifdef ESH_PRINTF if (okay == 1) diff --git a/sys/dev/ic/sl811hs.c b/sys/dev/ic/sl811hs.c index 5bd82280f33..52c945ae199 100644 --- a/sys/dev/ic/sl811hs.c +++ b/sys/dev/ic/sl811hs.c @@ -1,4 +1,4 @@ -/* $NetBSD: sl811hs.c,v 1.3 2003/03/13 06:50:23 bsh Exp $ */ +/* $NetBSD: sl811hs.c,v 1.4 2004/04/22 00:17:11 itojun Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.3 2003/03/13 06:50:23 bsh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.4 2004/04/22 00:17:11 itojun Exp $"); #include "opt_slhci.h" @@ -807,7 +807,8 @@ slhci_root_ctrl_start(usbd_xfer_handle xfer) totlen = slhci_str(buf, len, "ScanLogic"); break; case 2: /* Product */ - sprintf(slbuf, "%s root hub", sltypestr[sc->sc_sltype]); + snprintf(slbuf, sizeof(slbuf), "%s root hub", + sltypestr[sc->sc_sltype]); totlen = slhci_str(buf, len, slbuf); break; default: diff --git a/sys/dev/ic/tms320av110.c b/sys/dev/ic/tms320av110.c index 8e866c44135..8afbb42c738 100644 --- a/sys/dev/ic/tms320av110.c +++ b/sys/dev/ic/tms320av110.c @@ -1,4 +1,4 @@ -/* $NetBSD: tms320av110.c,v 1.12 2003/01/06 13:05:11 wiz Exp $ */ +/* $NetBSD: tms320av110.c,v 1.13 2004/04/22 00:17:11 itojun Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tms320av110.c,v 1.12 2003/01/06 13:05:11 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tms320av110.c,v 1.13 2004/04/22 00:17:11 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -360,10 +360,11 @@ tav_getdev(hdl, ret) iot = sc->sc_iot; ioh = sc->sc_ioh; - strncpy(ret->name, "tms320av110", MAX_AUDIO_DEV_LEN); - sprintf(ret->version, "%u", /* guaranteed to be <= 4 in length */ + strlcpy(ret->name, "tms320av110", sizeof(ret->name)); + /* guaranteed to be <= 4 in length */ + snprintf(ret->version, sizeof(ret->version), "%u", tav_read_byte(iot, ioh, TAV_VERSION)); - strncpy(ret->config, sc->sc_dev.dv_xname, MAX_AUDIO_DEV_LEN); + strlcpy(ret->config, sc->sc_dev.dv_xname, sizeof(ret->config)); return 0; } diff --git a/sys/dev/isa/aria.c b/sys/dev/isa/aria.c index 39df1e161cc..6dd6531ee65 100644 --- a/sys/dev/isa/aria.c +++ b/sys/dev/isa/aria.c @@ -1,4 +1,4 @@ -/* $NetBSD: aria.c,v 1.18 2003/05/03 18:11:26 wiz Exp $ */ +/* $NetBSD: aria.c,v 1.19 2004/04/22 00:17:11 itojun Exp $ */ /*- * Copyright (c) 1995, 1996, 1998 Roland C. Dowdeswell. All rights reserved. @@ -50,7 +50,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: aria.c,v 1.18 2003/05/03 18:11:26 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: aria.c,v 1.19 2004/04/22 00:17:11 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -475,7 +475,7 @@ ariaattach(parent, self, aux) printf(", SC18075 mixer"); printf("\n"); - sprintf(aria_device.version, "%s", + snprintf(aria_device.version, sizeof(aria_device.version), "%s", ARIA_MODEL & sc->sc_hardware ? "SC18026" : "SC18025"); audio_attach_mi(&aria_hw_if, (void *)sc, &sc->sc_dev); diff --git a/sys/dev/isa/ess.c b/sys/dev/isa/ess.c index cf5106c11cd..581b9b80fb5 100644 --- a/sys/dev/isa/ess.c +++ b/sys/dev/isa/ess.c @@ -1,4 +1,4 @@ -/* $NetBSD: ess.c,v 1.58 2003/05/09 23:51:28 fvdl Exp $ */ +/* $NetBSD: ess.c,v 1.59 2004/04/22 00:17:11 itojun Exp $ */ /* * Copyright 1997 @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ess.c,v 1.58 2003/05/09 23:51:28 fvdl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ess.c,v 1.59 2004/04/22 00:17:11 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1018,8 +1018,10 @@ essattach(sc) ess_speaker_off(sc); sc->spkr_state = SPKR_OFF; - sprintf(ess_device.name, "ES%s", essmodel[sc->sc_model]); - sprintf(ess_device.version, "0x%04x", sc->sc_version); + snprintf(ess_device.name, sizeof(ess_device.name), "ES%s", + essmodel[sc->sc_model]); + snprintf(ess_device.version, sizeof(ess_device.version), "0x%04x", + sc->sc_version); if (ESS_USE_AUDIO1(sc->sc_model)) audio_attach_mi(&ess_1788_hw_if, sc, &sc->sc_dev); diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index e295d405d72..f7142395a8a 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $NetBSD: gus.c,v 1.82 2003/11/21 03:08:37 gson Exp $ */ +/* $NetBSD: gus.c,v 1.83 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 1996, 1999 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.82 2003/11/21 03:08:37 gson Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.83 2004/04/22 00:17:12 itojun Exp $"); #include "gus.h" #if NGUS > 0 @@ -1030,7 +1030,8 @@ gusattach(parent, self, aux) * of the board version. Simply use the revision register as * identification. */ - sprintf(gus_device.version, "%d", sc->sc_revision); + snprintf(gus_device.version, sizeof(gus_device.version), "%d", + sc->sc_revision); printf("\n%s: Gravis UltraSound", sc->sc_dev.dv_xname); if (sc->sc_revision >= 10) diff --git a/sys/dev/isa/if_ai.c b/sys/dev/isa/if_ai.c index 7a24e7462a4..05a88f98607 100644 --- a/sys/dev/isa/if_ai.c +++ b/sys/dev/isa/if_ai.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ai.c,v 1.17 2002/10/02 03:10:47 thorpej Exp $ */ +/* $NetBSD: if_ai.c,v 1.18 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ai.c,v 1.17 2002/10/02 03:10:47 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ai.c,v 1.18 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -427,8 +427,8 @@ ai_attach(parent, self, aux) val = bus_space_read_1(asc->sc_regt, asc->sc_regh, AI_REVISION); asc->card_rev = SL_REV(val); asc->card_type = SL_BOARD(val) - 1; - sprintf(name, "%s, rev. %d", - ai_names[asc->card_type], asc->card_rev); + snprintf(name, sizeof(name), "%s, rev. %d", + ai_names[asc->card_type], asc->card_rev); i82586_attach(sc, name, ethaddr, NULL, 0, 0); diff --git a/sys/dev/isa/if_ef.c b/sys/dev/isa/if_ef.c index 010f04a5cd1..0fafbfa2385 100644 --- a/sys/dev/isa/if_ef.c +++ b/sys/dev/isa/if_ef.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ef.c,v 1.15 2002/10/02 03:10:47 thorpej Exp $ */ +/* $NetBSD: if_ef.c,v 1.16 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.15 2002/10/02 03:10:47 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.16 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -658,7 +658,7 @@ ef_attach(parent, self, aux) ethaddr[i] = bus_space_read_1(esc->sc_regt, esc->sc_regh, EF_ADDR + i); - sprintf(version, "%s, rev. %d", + snprintf(version, sizeof(version), "%s, rev. %d", (esc->card_type == EF_CARD_TP) ? "3C507-TP" : "3C507", esc->card_rev); diff --git a/sys/dev/isa/if_lc_isa.c b/sys/dev/isa/if_lc_isa.c index e1275077b4b..2c5029edc3e 100644 --- a/sys/dev/isa/if_lc_isa.c +++ b/sys/dev/isa/if_lc_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_lc_isa.c,v 1.16 2002/10/02 03:10:48 thorpej Exp $ */ +/* $NetBSD: if_lc_isa.c,v 1.17 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 1994, 1995, 1997 Matt Thomas <matt@3am-software.com> @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_lc_isa.c,v 1.16 2002/10/02 03:10:48 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lc_isa.c,v 1.17 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -190,7 +190,8 @@ lemac_isa_probe(parent, match, aux) struct isa_attach_args *ia = aux; struct cfdata *cf = match; lemac_softc_t sc; - (void)sprintf(sc.sc_dv.dv_xname, "%s%d", lc_cd.cd_name, cf->cf_unit); + snprintf(sc.sc_dv.dv_xname, sizeof(sc.sc_dv.dv_xname), "%s%d", + lc_cd.cd_name, cf->cf_unit); return lemac_isa_find(&sc, ia, 0); } diff --git a/sys/dev/isa/opl_ym.c b/sys/dev/isa/opl_ym.c index 7f6a9d7c90f..f90409f4237 100644 --- a/sys/dev/isa/opl_ym.c +++ b/sys/dev/isa/opl_ym.c @@ -1,4 +1,4 @@ -/* $NetBSD: opl_ym.c,v 1.6 2002/10/02 03:10:49 thorpej Exp $ */ +/* $NetBSD: opl_ym.c,v 1.7 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: opl_ym.c,v 1.6 2002/10/02 03:10:49 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: opl_ym.c,v 1.7 2004/04/22 00:17:12 itojun Exp $"); #include "mpu_ym.h" @@ -107,7 +107,8 @@ opl_ym_attach(parent, self, aux) sc->powerctl = opl_ym_power_ctl; sc->powerarg = ssc; #endif - sprintf(sc->syn.name, "%s ", ssc->sc_ad1848.sc_ad1848.chip_name); + snprintf(sc->syn.name, sizeof(sc->syn.name), "%s ", + ssc->sc_ad1848.sc_ad1848.chip_name); opl_attach(sc); } diff --git a/sys/dev/isa/pas.c b/sys/dev/isa/pas.c index 3b9215fdf8c..34944991269 100644 --- a/sys/dev/isa/pas.c +++ b/sys/dev/isa/pas.c @@ -1,4 +1,4 @@ -/* $NetBSD: pas.c,v 1.57 2003/05/03 18:11:27 wiz Exp $ */ +/* $NetBSD: pas.c,v 1.58 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -57,7 +57,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pas.c,v 1.57 2003/05/03 18:11:27 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pas.c,v 1.58 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -486,8 +486,10 @@ pasattach(parent, self, aux) sbdsp_attach(&sc->sc_sbdsp); - sprintf(pas_device.name, "pas,%s", pasnames[sc->model]); - sprintf(pas_device.version, "%d", sc->rev); + snprintf(pas_device.name, sizeof(pas_device.name), "pas,%s", + pasnames[sc->model]); + snprintf(pas_device.version, sizeof(pas_device.version), "%d", + sc->rev); audio_attach_mi(&pas_hw_if, &sc->sc_sbdsp, &sc->sc_sbdsp.sc_dev); } diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c index 7f5ddeb2bf5..adcf898ec14 100644 --- a/sys/dev/isa/sb.c +++ b/sys/dev/isa/sb.c @@ -1,4 +1,4 @@ -/* $NetBSD: sb.c,v 1.76 2003/12/04 13:57:30 keihan Exp $ */ +/* $NetBSD: sb.c,v 1.77 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sb.c,v 1.76 2003/12/04 13:57:30 keihan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sb.c,v 1.77 2004/04/22 00:17:12 itojun Exp $"); #include "midi.h" @@ -268,17 +268,16 @@ sb_getdev(addr, retp) const char *config; if (sc->sc_model == SB_JAZZ) - strncpy(retp->name, "MV Jazz16", sizeof(retp->name)); + strlcpy(retp->name, "MV Jazz16", sizeof(retp->name)); else - strncpy(retp->name, "SoundBlaster", sizeof(retp->name)); - sprintf(retp->version, "%d.%02d", - SBVER_MAJOR(sc->sc_version), - SBVER_MINOR(sc->sc_version)); + strlcpy(retp->name, "SoundBlaster", sizeof(retp->name)); + snprintf(retp->version, sizeof(retp->version), "%d.%02d", + SBVER_MAJOR(sc->sc_version), SBVER_MINOR(sc->sc_version)); if (0 <= sc->sc_model && sc->sc_model < sizeof names / sizeof names[0]) config = names[sc->sc_model]; else config = "??"; - strncpy(retp->config, config, sizeof(retp->config)); + strlcpy(retp->config, config, sizeof(retp->config)); return 0; } diff --git a/sys/dev/isa/ym.c b/sys/dev/isa/ym.c index b52ccd90218..7dbb88047fe 100644 --- a/sys/dev/isa/ym.c +++ b/sys/dev/isa/ym.c @@ -1,4 +1,4 @@ -/* $NetBSD: ym.c,v 1.21 2002/03/10 13:57:11 itohy Exp $ */ +/* $NetBSD: ym.c,v 1.22 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 1999-2002 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ym.c,v 1.21 2002/03/10 13:57:11 itohy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ym.c,v 1.22 2004/04/22 00:17:12 itojun Exp $"); #include "mpu_ym.h" #include "opt_ym.h" @@ -416,9 +416,9 @@ ym_getdev(addr, retp) struct ym_softc *sc = addr; struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848; - strcpy(retp->name, ac->chip_name); - sprintf(retp->version, "%d", sc->sc_version); - strcpy(retp->config, "ym"); + strlcpy(retp->name, ac->chip_name, sizeof(retp->name)); + snprintf(retp->version, sizeof(retp->version), "%d", sc->sc_version); + strlcpy(retp->config, "ym", sizeof(retp->config)); return 0; } diff --git a/sys/dev/mca/mca.c b/sys/dev/mca/mca.c index 48559857069..31dc5bf2ef7 100644 --- a/sys/dev/mca/mca.c +++ b/sys/dev/mca/mca.c @@ -1,4 +1,4 @@ -/* $NetBSD: mca.c,v 1.13 2003/01/01 00:10:21 thorpej Exp $ */ +/* $NetBSD: mca.c,v 1.14 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mca.c,v 1.13 2003/01/01 00:10:21 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mca.c,v 1.14 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -92,7 +92,7 @@ mca_print(aux, pnp) char devinfo[256]; if (pnp) { - mca_devinfo(ma->ma_id, devinfo); + mca_devinfo(ma->ma_id, devinfo, sizeof(devinfo)); aprint_normal("%s slot %d: %s", pnp, ma->ma_slot + 1, devinfo); } diff --git a/sys/dev/mca/mca_subr.c b/sys/dev/mca/mca_subr.c index 91e81709ffe..ccda26a3f58 100644 --- a/sys/dev/mca/mca_subr.c +++ b/sys/dev/mca/mca_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: mca_subr.c,v 1.5 2001/11/13 07:46:26 lukem Exp $ */ +/* $NetBSD: mca_subr.c,v 1.6 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mca_subr.c,v 1.5 2001/11/13 07:46:26 lukem Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mca_subr.c,v 1.6 2004/04/22 00:17:12 itojun Exp $"); #include "opt_mcaverbose.h" @@ -67,9 +67,10 @@ struct mca_knowndev { #endif /* MCAVERBOSE */ void -mca_devinfo(id, cp) +mca_devinfo(id, cp, l) int id; char *cp; + size_t l; { #ifdef MCAVERBOSE const struct mca_knowndev *kdp; @@ -78,10 +79,10 @@ mca_devinfo(id, cp) for (; kdp->name != NULL && kdp->id != id; kdp++); if (kdp->name != NULL) - sprintf(cp, "%s (0x%04x)", kdp->name, id); + snprintf(cp, l, "%s (0x%04x)", kdp->name, id); else #endif /* MCAVERBOSE */ - sprintf(cp, "product 0x%04x", id); + snprintf(cp, l, "product 0x%04x", id); } /* diff --git a/sys/dev/mca/mcavar.h b/sys/dev/mca/mcavar.h index a29d408cc69..a3b9b103a78 100644 --- a/sys/dev/mca/mcavar.h +++ b/sys/dev/mca/mcavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcavar.h,v 1.3 2001/04/27 17:11:45 jdolecek Exp $ */ +/* $NetBSD: mcavar.h,v 1.4 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ struct mca_attach_args { #define mcacf_slot cf_loc[0] #define MCA_UNKNOWN_SLOT -1 /* wildcarded 'slot' */ -void mca_devinfo __P((int, char *)); +void mca_devinfo __P((int, char *, size_t)); int mca_match_disabled __P((int)); #endif /* _DEV_MCA_MCAVAR_H_ */ diff --git a/sys/dev/mvme/memc.c b/sys/dev/mvme/memc.c index 2788981be7f..55af5c01ed3 100644 --- a/sys/dev/mvme/memc.c +++ b/sys/dev/mvme/memc.c @@ -1,4 +1,4 @@ -/* $NetBSD: memc.c,v 1.2 2003/07/14 15:47:20 lukem Exp $ */ +/* $NetBSD: memc.c,v 1.3 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 2000, 2002 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: memc.c,v 1.2 2003/07/14 15:47:20 lukem Exp $"); +__KERNEL_RCSID(0, "$NetBSD: memc.c,v 1.3 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -588,11 +588,12 @@ memecc_log_error(struct memc_softc *sc, u_int8_t errlog, int off, int mbepanic) strcpy(syntext, "Invalid!"); else if ((syncode & MEMECC_SYN_CHECKBIT_ERR) != 0) - sprintf(syntext, "Checkbit#%d", bitnum); + snprintf(syntext, sizeof(syntext), + "Checkbit#%d", bitnum); else { addr |= (u_int32_t) (bank << 2); - sprintf(syntext, "DRAM Bank %c, Bit#%d", - 'A' + bank, bitnum); + snprintf(syntext, sizeof(syntext), + "DRAM Bank %c, Bit#%d", 'A' + bank, bitnum); } } else if ((errlog & MEMECC_ERROR_LOGGER_MBE) != 0) etype = "Uncorrectable"; diff --git a/sys/dev/mvme/mvmebus.c b/sys/dev/mvme/mvmebus.c index 594308a3dcc..50750f47e58 100644 --- a/sys/dev/mvme/mvmebus.c +++ b/sys/dev/mvme/mvmebus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mvmebus.c,v 1.7 2004/02/13 11:36:22 wiz Exp $ */ +/* $NetBSD: mvmebus.c,v 1.8 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 2000, 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mvmebus.c,v 1.7 2004/02/13 11:36:22 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mvmebus.c,v 1.8 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -919,29 +919,29 @@ mvmebus_mod_string(addr, len, am, ds) "A16:%04x-%04x ", "A24:%06x-%06x " }; static char mstring[40]; - sprintf(mstring, + snprintf(mstring, sizeof(mstring), adrfmt[(am & VME_AM_ADRSIZEMASK) >> VME_AM_ADRSIZESHIFT], addr, addr + len - 1); - strcat(mstring, dsiz[ds & 0x7]); + strlcat(mstring, dsiz[ds & 0x7], sizeof(mstring, sizeof(mstring))); if (MVMEBUS_AM_HAS_CAP(am)) { if (am & MVMEBUS_AM_CAP_DATA) - strcat(mstring, "D"); + strlcat(mstring, "D", sizeof(mstring)); if (am & MVMEBUS_AM_CAP_PROG) - strcat(mstring, "P"); + strlcat(mstring, "P", sizeof(mstring)); if (am & MVMEBUS_AM_CAP_USER) - strcat(mstring, "U"); + strlcat(mstring, "U", sizeof(mstring)); if (am & MVMEBUS_AM_CAP_SUPER) - strcat(mstring, "S"); + strlcat(mstring, "S", sizeof(mstring)); if (am & MVMEBUS_AM_CAP_BLK) - strcat(mstring, "B"); + strlcat(mstring, "B", sizeof(mstring)); if (am & MVMEBUS_AM_CAP_BLKD64) - strcat(mstring, "6"); - strcat(mstring, ")"); + strlcat(mstring, "6", sizeof(mstring)); + strlcat(mstring, ")", sizeof(mstring)); } else { - strcat(mstring, ((am & VME_AM_PRIVMASK) == VME_AM_USER) ? - "USER," : "SUPER,"); - strcat(mstring, mode[am & VME_AM_MODEMASK]); + strlcat(mstring, ((am & VME_AM_PRIVMASK) == VME_AM_USER) ? + "USER," : "SUPER,", sizeof(mstring)); + strlcat(mstring, mode[am & VME_AM_MODEMASK], sizeof(mstring)); } return (mstring); diff --git a/sys/dev/ofisa/ofisa.c b/sys/dev/ofisa/ofisa.c index 3f9ce75c131..f53d7452f25 100644 --- a/sys/dev/ofisa/ofisa.c +++ b/sys/dev/ofisa/ofisa.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofisa.c,v 1.13 2003/01/01 00:10:22 thorpej Exp $ */ +/* $NetBSD: ofisa.c,v 1.14 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright 1997, 1998 @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ofisa.c,v 1.13 2003/01/01 00:10:22 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofisa.c,v 1.14 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -398,7 +398,8 @@ ofisa_dma_print(descp, ndescs) modestr = "C"; break; default: - sprintf(unkmode, "??? (%d)", descp[i].mode); + snprintf(unkmode, sizeof(unkmode), "??? (%d)", + descp[i].mode); modestr = unkmode; break; } diff --git a/sys/dev/ofw/ofbus.c b/sys/dev/ofw/ofbus.c index e2b27fbaf5a..ca9f41c99a0 100644 --- a/sys/dev/ofw/ofbus.c +++ b/sys/dev/ofw/ofbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofbus.c,v 1.17 2003/01/01 00:10:22 thorpej Exp $ */ +/* $NetBSD: ofbus.c,v 1.18 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ofbus.c,v 1.17 2003/01/01 00:10:22 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofbus.c,v 1.18 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -110,10 +110,12 @@ ofbus_attach(parent, dev, aux) for (oba2.oba_unit = 0; oba2.oba_unit < units; oba2.oba_unit++) { if (units > 1) { - sprintf(oba2.oba_ofname, "%s@%d", name, - oba2.oba_unit); + snprintf(oba2.oba_ofname, + sizeof(oba2.oba_ofname), "%s@%d", name, + oba2.oba_unit); } else { - strcpy(oba2.oba_ofname, name); + strlcpy(oba2.oba_ofname, name, + sizeof(oba2.oba_ofname)); } config_found(dev, &oba2, ofbus_print); } diff --git a/sys/dev/ofw/ofw_subr.c b/sys/dev/ofw/ofw_subr.c index b93d6b1e0dc..3aed1ed2ec5 100644 --- a/sys/dev/ofw/ofw_subr.c +++ b/sys/dev/ofw/ofw_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofw_subr.c,v 1.8 2003/01/06 13:26:27 wiz Exp $ */ +/* $NetBSD: ofw_subr.c,v 1.9 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright 1998 @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.8 2003/01/06 13:26:27 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.9 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -190,11 +190,10 @@ of_packagename(phandle, buf, bufsize) /* check that we could get the name, and that it's not too long. */ if (l < 0 || (l == OFW_PATH_BUF_SIZE && pbuf[OFW_PATH_BUF_SIZE - 1] != '\0')) { - /* XXX should use snprintf! */ if (bufsize >= 25) - sprintf(buf, "??? (phandle 0x%x)", phandle); + snprintf(buf, bufsize, "??? (phandle 0x%x)", phandle); else if (bufsize >= 4) - strcpy(buf, "???"); + strlcpy(buf, "???", bufsize); else panic("of_packagename: bufsize = %d is silly", bufsize); @@ -202,9 +201,8 @@ of_packagename(phandle, buf, bufsize) } else { pbuf[l] = '\0'; lastslash = strrchr(pbuf, '/'); - strncpy(buf, (lastslash == NULL) ? pbuf : (lastslash + 1), + strlcpy(buf, (lastslash == NULL) ? pbuf : (lastslash + 1), bufsize); - buf[bufsize - 1] = '\0'; /* in case it's fills the buffer. */ rv = 0; } diff --git a/sys/dev/pci/amr.c b/sys/dev/pci/amr.c index 7d4cba4f20f..8e8574ab6b5 100644 --- a/sys/dev/pci/amr.c +++ b/sys/dev/pci/amr.c @@ -1,4 +1,4 @@ -/* $NetBSD: amr.c,v 1.19 2003/11/05 16:03:27 fvdl Exp $ */ +/* $NetBSD: amr.c,v 1.20 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: amr.c,v 1.19 2003/11/05 16:03:27 fvdl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amr.c,v 1.20 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -619,7 +619,8 @@ amr_init(struct amr_softc *amr, const char *intrstr, i++; } if (i == sizeof(amr_typestr) / sizeof(amr_typestr[0])) { - sprintf(buf, "unknown ENQUIRY2 sig (0x%08x)", sig); + snprintf(buf, sizeof(buf), + "unknown ENQUIRY2 sig (0x%08x)", sig); prodstr = buf; } else prodstr = amr_typestr[i].at_str; @@ -639,7 +640,7 @@ amr_init(struct amr_softc *amr, const char *intrstr, prodstr = "Series 434"; break; default: - sprintf(buf, "unknown PCI dev (0x%04x)", + snprintf(buf, sizeof(buf), "unknown PCI dev (0x%04x)", PCI_PRODUCT(pa->pa_id)); prodstr = buf; break; diff --git a/sys/dev/pci/auvia.c b/sys/dev/pci/auvia.c index 2804eca625e..bd7ee0dd07c 100644 --- a/sys/dev/pci/auvia.c +++ b/sys/dev/pci/auvia.c @@ -1,4 +1,4 @@ -/* $NetBSD: auvia.c,v 1.38 2004/04/12 15:44:53 jmmv Exp $ */ +/* $NetBSD: auvia.c,v 1.39 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.38 2004/04/12 15:44:53 jmmv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.39 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -285,7 +285,7 @@ auvia_attach(struct device *parent, struct device *self, void *aux) r = PCI_REVISION(pa->pa_class); if (sc->sc_flags & AUVIA_FLAGS_VT8233) { - sprintf(sc->sc_revision, "0x%02X", r); + snprintf(sc->sc_revision, sizeof(sc->sc_revision), "0x%02X", r); switch(r) { case VIA_REV_8233C: /* 2 rec, 4 pb, 1 multi-pb */ @@ -313,7 +313,8 @@ auvia_attach(struct device *parent, struct device *self, void *aux) } else if ((r >= 0x10) && (r <= 0x14)) { sc->sc_revision[0] = 'A' + (r - 0x10); } else { - sprintf(sc->sc_revision, "0x%02X", r); + snprintf(sc->sc_revision, sizeof(sc->sc_revision), + "0x%02X", r); } aprint_normal(": VIA Technologies VT82C686A AC'97 Audio " diff --git a/sys/dev/pci/ehci_pci.c b/sys/dev/pci/ehci_pci.c index 64f8503c68b..c1802566ab7 100644 --- a/sys/dev/pci/ehci_pci.c +++ b/sys/dev/pci/ehci_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ehci_pci.c,v 1.13 2003/01/31 00:07:41 thorpej Exp $ */ +/* $NetBSD: ehci_pci.c,v 1.14 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.13 2003/01/31 00:07:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.14 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -172,11 +172,10 @@ ehci_pci_attach(struct device *parent, struct device *self, void *aux) vendor = pci_findvendor(pa->pa_id); sc->sc.sc_id_vendor = PCI_VENDOR(pa->pa_id); if (vendor) - strncpy(sc->sc.sc_vendor, vendor, - sizeof(sc->sc.sc_vendor) - 1); + strlcpy(sc->sc.sc_vendor, vendor, sizeof(sc->sc.sc_vendor)); else - sprintf(sc->sc.sc_vendor, "vendor 0x%04x", - PCI_VENDOR(pa->pa_id)); + snprintf(sc->sc.sc_vendor, sizeof(sc->sc.sc_vendor), + "vendor 0x%04x", PCI_VENDOR(pa->pa_id)); /* * Find companion controllers. According to the spec they always diff --git a/sys/dev/pci/if_dge.c b/sys/dev/pci/if_dge.c index 327c256c0cd..1765289644d 100644 --- a/sys/dev/pci/if_dge.c +++ b/sys/dev/pci/if_dge.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_dge.c,v 1.3 2004/04/14 17:31:02 ragge Exp $ */ +/* $NetBSD: if_dge.c,v 1.4 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 2004, SUNET, Swedish University Computer Network. @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.3 2004/04/14 17:31:02 ragge Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.4 2004/04/22 00:17:12 itojun Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -917,7 +917,8 @@ dge_attach(struct device *parent, struct device *self, void *aux) dge_txseg_evcnt_names = malloc(sizeof(*dge_txseg_evcnt_names), M_DEVBUF, M_WAITOK); for (i = 0; i < DGE_NTXSEGS; i++) - sprintf((*dge_txseg_evcnt_names)[i], "txseg%d", i); + snprintf((*dge_txseg_evcnt_names)[i], + sizeof((*dge_txseg_evcnt_names)[i]), "txseg%d", i); } /* Attach event counters. */ diff --git a/sys/dev/pci/ld_twe.c b/sys/dev/pci/ld_twe.c index b99730ce332..2b84a9c9de7 100644 --- a/sys/dev/pci/ld_twe.c +++ b/sys/dev/pci/ld_twe.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld_twe.c,v 1.18 2003/09/26 03:11:41 thorpej Exp $ */ +/* $NetBSD: ld_twe.c,v 1.19 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ld_twe.c,v 1.18 2003/09/26 03:11:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_twe.c,v 1.19 2004/04/22 00:17:12 itojun Exp $"); #include "rnd.h" @@ -128,7 +128,7 @@ ld_twe_attach(struct device *parent, struct device *self, void *aux) typestr = twe_describe_code(twe_table_unittype, td->td_type); if (typestr == NULL) { - sprintf(unktype, "<0x%02x>", td->td_type); + snprintf(unktype, sizeof(unktype), "<0x%02x>", td->td_type); typestr = unktype; } switch (td->td_type) { @@ -138,10 +138,11 @@ ld_twe_attach(struct device *parent, struct device *self, void *aux) stripestr = twe_describe_code(twe_table_stripedepth, td->td_stripe); if (stripestr == NULL) - sprintf(stripebuf, "<stripe code 0x%02x> ", - td->td_stripe); + snprintf(stripebuf, sizeof(stripebuf), + "<stripe code 0x%02x> ", td->td_stripe); else - sprintf(stripebuf, "%s stripe ", stripestr); + snprintf(stripebuf, sizeof(stripebuf), "%s stripe ", + stripestr); break; default: stripebuf[0] = '\0'; @@ -151,11 +152,12 @@ ld_twe_attach(struct device *parent, struct device *self, void *aux) TWE_PARAM_UNITINFO_Status, &status); status &= TWE_PARAM_UNITSTATUS_MASK; if (error) { - sprintf(unkstat, "<unknown>"); + snprintf(unkstat, sizeof(unkstat), "<unknown>"); statstr = unkstat; } else if ((statstr = twe_describe_code(twe_table_unitstate, status)) == NULL) { - sprintf(unkstat, "<status code 0x%02x>", status); + snprintf(unkstat, sizeof(unkstat), "<status code 0x%02x>", + status); statstr = unkstat; } diff --git a/sys/dev/pci/ohci_pci.c b/sys/dev/pci/ohci_pci.c index 7280dde7b39..f2cab1b9245 100644 --- a/sys/dev/pci/ohci_pci.c +++ b/sys/dev/pci/ohci_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ohci_pci.c,v 1.23 2002/10/02 16:51:47 thorpej Exp $ */ +/* $NetBSD: ohci_pci.c,v 1.24 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v 1.23 2002/10/02 16:51:47 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v 1.24 2004/04/22 00:17:12 itojun Exp $"); #include "ehci.h" @@ -148,11 +148,10 @@ ohci_pci_attach(struct device *parent, struct device *self, void *aux) vendor = pci_findvendor(pa->pa_id); sc->sc.sc_id_vendor = PCI_VENDOR(pa->pa_id); if (vendor) - strncpy(sc->sc.sc_vendor, vendor, - sizeof(sc->sc.sc_vendor) - 1); + strlcpy(sc->sc.sc_vendor, vendor, sizeof(sc->sc.sc_vendor)); else - sprintf(sc->sc.sc_vendor, "vendor 0x%04x", - PCI_VENDOR(pa->pa_id)); + snprintf(sc->sc.sc_vendor, sizeof(sc->sc.sc_vendor), + "vendor 0x%04x", PCI_VENDOR(pa->pa_id)); r = ohci_init(&sc->sc); if (r != USBD_NORMAL_COMPLETION) { diff --git a/sys/dev/pci/uhci_pci.c b/sys/dev/pci/uhci_pci.c index a3293dc9638..b50757b5281 100644 --- a/sys/dev/pci/uhci_pci.c +++ b/sys/dev/pci/uhci_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhci_pci.c,v 1.24 2002/10/02 16:51:58 thorpej Exp $ */ +/* $NetBSD: uhci_pci.c,v 1.25 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.24 2002/10/02 16:51:58 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.25 2004/04/22 00:17:12 itojun Exp $"); #include "ehci.h" @@ -167,11 +167,10 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux) vendor = pci_findvendor(pa->pa_id); sc->sc.sc_id_vendor = PCI_VENDOR(pa->pa_id); if (vendor) - strncpy(sc->sc.sc_vendor, vendor, - sizeof(sc->sc.sc_vendor) - 1); + strlcpy(sc->sc.sc_vendor, vendor, sizeof(sc->sc.sc_vendor)); else - sprintf(sc->sc.sc_vendor, "vendor 0x%04x", - PCI_VENDOR(pa->pa_id)); + snprintf(sc->sc.sc_vendor, sizeof(sc->sc.sc_vendor), + "vendor 0x%04x", PCI_VENDOR(pa->pa_id)); r = uhci_init(&sc->sc); if (r != USBD_NORMAL_COMPLETION) { diff --git a/sys/dev/podulebus/hcsc.c b/sys/dev/podulebus/hcsc.c index e40d0b22d0f..8d5667a8112 100644 --- a/sys/dev/podulebus/hcsc.c +++ b/sys/dev/podulebus/hcsc.c @@ -1,4 +1,4 @@ -/* $NetBSD: hcsc.c,v 1.12 2002/10/02 16:52:23 thorpej Exp $ */ +/* $NetBSD: hcsc.c,v 1.13 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 2001 Ben Harris @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hcsc.c,v 1.12 2002/10/02 16:52:23 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hcsc.c,v 1.13 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> @@ -209,7 +209,8 @@ hcsc_attach(struct device *parent, struct device *self, void *aux) /* Provide an override for the host id */ sc->sc_ncr5380.sc_channel.chan_id = 7; - sprintf(hi_option, "%s.hostid", sc->sc_ncr5380.sc_dev.dv_xname); + snprintf(hi_option, sizeof(hi_option), "%s.hostid", + sc->sc_ncr5380.sc_dev.dv_xname); (void)get_bootconf_option(boot_args, hi_option, BOOTOPT_TYPE_INT, &sc->sc_ncr5380.sc_channel.chan_id); sc->sc_ncr5380.sc_adapter.adapt_minphys = minphys; diff --git a/sys/dev/podulebus/oak.c b/sys/dev/podulebus/oak.c index 5ca432746e8..9fe9f370f07 100644 --- a/sys/dev/podulebus/oak.c +++ b/sys/dev/podulebus/oak.c @@ -1,4 +1,4 @@ -/* $NetBSD: oak.c,v 1.12 2002/10/02 16:52:24 thorpej Exp $ */ +/* $NetBSD: oak.c,v 1.13 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: oak.c,v 1.12 2002/10/02 16:52:24 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: oak.c,v 1.13 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> @@ -199,7 +199,8 @@ oak_attach(struct device *parent, struct device *self, void *aux) /* Provide an override for the host id */ sc->sc_ncr5380.sc_channel.chan_id = 7; - sprintf(hi_option, "%s.hostid", sc->sc_ncr5380.sc_dev.dv_xname); + snprintf(hi_option, sizeof(hi_option), "%s.hostid", + sc->sc_ncr5380.sc_dev.dv_xname); (void)get_bootconf_option(boot_args, hi_option, BOOTOPT_TYPE_INT, &sc->sc_ncr5380.sc_channel.chan_id); sc->sc_ncr5380.sc_adapter.adapt_minphys = minphys; diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c index 79657bd3f65..12f6adc3a65 100644 --- a/sys/dev/raidframe/rf_disks.c +++ b/sys/dev/raidframe/rf_disks.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_disks.c,v 1.51 2004/03/21 06:32:03 oster Exp $ */ +/* $NetBSD: rf_disks.c,v 1.52 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -67,7 +67,7 @@ ***************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.51 2004/03/21 06:32:03 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.52 2004/04/22 00:17:12 itojun Exp $"); #include <dev/raidframe/raidframevar.h> @@ -465,9 +465,9 @@ rf_AutoConfigureDisks(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, raidPtr->raid_cinfo[c].ci_dev = ac->dev; memcpy(&raidPtr->raid_cinfo[c].ci_label, - ac->clabel, sizeof(*ac->clabel)); - sprintf(diskPtr->devname, "/dev/%s", - ac->devname); + ac->clabel, sizeof(*ac->clabel)); + snprintf(diskPtr->devname, sizeof(diskPtr->devname), + "/dev/%s", ac->devname); /* note the fact that this component was autoconfigured. You'll need this info @@ -517,7 +517,8 @@ rf_AutoConfigureDisks(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, /* Didn't find it at all!! Component must really be dead */ disks[c].status = rf_ds_failed; - sprintf(disks[c].devname, "component%d", c); + snprintf(disks[c].devname, sizeof(disks[c].devname), + "component%d", c); numFailuresThisRow++; } } diff --git a/sys/dev/raidframe/rf_driver.c b/sys/dev/raidframe/rf_driver.c index 3b0713f98e3..240230e4d64 100644 --- a/sys/dev/raidframe/rf_driver.c +++ b/sys/dev/raidframe/rf_driver.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_driver.c,v 1.100 2004/04/10 05:52:33 oster Exp $ */ +/* $NetBSD: rf_driver.c,v 1.101 2004/04/22 00:17:12 itojun Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -73,7 +73,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.100 2004/04/10 05:52:33 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.101 2004/04/22 00:17:12 itojun Exp $"); #include "opt_raid_diagnostic.h" @@ -840,15 +840,15 @@ rf_ConfigureDebug(RF_Config_t *cfgPtr) void rf_print_panic_message(int line, char *file) { - sprintf(rf_panicbuf,"raidframe error at line %d file %s", - line, file); + snprintf(rf_panicbuf, sizeof(rf_panicbuf), + "raidframe error at line %d file %s", line, file); } #ifdef RAID_DIAGNOSTIC void rf_print_assert_panic_message(int line, char *file, char *condition) { - sprintf(rf_panicbuf, + snprintf(rf_panicbuf, sizeof(rf_panicbuf), "raidframe error at line %d file %s (failed asserting %s)\n", line, file, condition); } diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 1714d00e4b1..91001a3167e 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.178 2004/03/07 22:15:19 oster Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.179 2004/04/22 00:17:13 itojun Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -146,7 +146,7 @@ ***********************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.178 2004/03/07 22:15:19 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.179 2004/04/22 00:17:13 itojun Exp $"); #include <sys/param.h> #include <sys/errno.h> @@ -403,7 +403,8 @@ raidattach(int num) raidrootdev[raidID].dv_unit = raidID; raidrootdev[raidID].dv_parent = NULL; raidrootdev[raidID].dv_flags = 0; - sprintf(raidrootdev[raidID].dv_xname,"raid%d",raidID); + snprintf(raidrootdev[raidID].dv_xname, + sizeof(raidrootdev[raidID].dv_xname), "raid%d", raidID); RF_Malloc(raidPtrs[raidID], sizeof(RF_Raid_t), (RF_Raid_t *)); @@ -1602,7 +1603,8 @@ raidinit(RF_Raid_t *raidPtr) /* XXX should check return code first... */ rs->sc_flags |= RAIDF_INITED; - sprintf(rs->sc_xname, "raid%d", unit); /* XXX doesn't check bounds. */ + /* XXX doesn't check bounds. */ + snprintf(rs->sc_xname, sizeof(rs->sc_xname), "raid%d", unit); rs->sc_dkdev.dk_name = rs->sc_xname; @@ -2722,8 +2724,9 @@ rf_find_raid_components() return(NULL); } - sprintf(ac->devname, "%s%c", - dv->dv_xname, 'a'+i); + snprintf(ac->devname, + sizeof(ac->devname), "%s%c", + dv->dv_xname, 'a'+i); ac->dev = dev; ac->vp = vp; ac->clabel = clabel; diff --git a/sys/dev/scsipi/scsipi_verbose.c b/sys/dev/scsipi/scsipi_verbose.c index d6c06379cbf..bba8c3921e6 100644 --- a/sys/dev/scsipi/scsipi_verbose.c +++ b/sys/dev/scsipi/scsipi_verbose.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsipi_verbose.c,v 1.20 2004/03/16 19:10:44 bouyer Exp $ */ +/* $NetBSD: scsipi_verbose.c,v 1.21 2004/04/22 00:17:13 itojun Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: scsipi_verbose.c,v 1.20 2004/03/16 19:10:44 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsipi_verbose.c,v 1.21 2004/04/22 00:17:13 itojun Exp $"); #include <sys/param.h> #include <sys/time.h> @@ -604,12 +604,14 @@ static const struct { { 0x00, 0x00, NULL } }; -static __inline void asc2ascii __P((unsigned char, unsigned char, char *)); +static __inline void asc2ascii __P((unsigned char, unsigned char, char *, + size_t)); static __inline void -asc2ascii(asc, ascq, result) +asc2ascii(asc, ascq, result, l) unsigned char asc, ascq; char *result; + size_t l; { int i = 0; @@ -620,14 +622,14 @@ asc2ascii(asc, ascq, result) } if (adesc[i].description == NULL) { if (asc == 0x40 && ascq != 0) - (void)sprintf(result, + (void)snprintf(result, l, "Diagnostic Failure on Component 0x%02x", ascq & 0xff); else - (void)sprintf(result, "ASC 0x%02x ASCQ 0x%02x", + (void)snprintf(result, l, "ASC 0x%02x ASCQ 0x%02x", asc & 0xff, ascq & 0xff); } else - (void)strcpy(result, adesc[i].description); + (void)strlcpy(result, adesc[i].description, l); } void @@ -767,12 +769,13 @@ scsipi_decode_sense(sinfo, flag) (void) strcpy(rqsbuf, sense_keys[skey]); return (rqsbuf); } else if (flag == 1) { /* ASC/ASCQ Only */ - asc2ascii(snsbuf[12], snsbuf[13], rqsbuf); + asc2ascii(snsbuf[12], snsbuf[13], rqsbuf, sizeof(rqsbuf)); return (rqsbuf); } else if (flag == 2) { /* Sense Key && ASC/ASCQ */ auto char localbuf[64]; - asc2ascii(snsbuf[12], snsbuf[13], localbuf); - (void) sprintf(rqsbuf, "%s, %s", sense_keys[skey], localbuf); + asc2ascii(snsbuf[12], snsbuf[13], localbuf, sizeof(localbuf)); + (void) snprintf(rqsbuf, sizeof(rqsbuf), "%s, %s", + sense_keys[skey], localbuf); return (rqsbuf); } else if (flag == 3 && snsbuf[7] >= 9 && (snsbuf[15] & 0x80)) { /* @@ -781,13 +784,13 @@ scsipi_decode_sense(sinfo, flag) switch (skey) { case SKEY_ILLEGAL_REQUEST: if (snsbuf[15] & 0x8) - (void)sprintf(rqsbuf, + (void)snprintf(rqsbuf, sizeof(rqsbuf), "Error in %s, Offset %d, bit %d", (snsbuf[15] & 0x40)? "CDB" : "Parameters", (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff), snsbuf[15] & 0x7); else - (void)sprintf(rqsbuf, + (void)snprintf(rqsbuf, sizeof(rqsbuf), "Error in %s, Offset %d", (snsbuf[15] & 0x40)? "CDB" : "Parameters", (snsbuf[16] & 0xff) << 8 | @@ -796,11 +799,13 @@ scsipi_decode_sense(sinfo, flag) case SKEY_RECOVERED_ERROR: case SKEY_MEDIUM_ERROR: case SKEY_HARDWARE_ERROR: - (void)sprintf(rqsbuf, "Actual Retry Count: %d", + (void)snprintf(rqsbuf, sizeof(rqsbuf), + "Actual Retry Count: %d", (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff)); return (rqsbuf); case SKEY_NOT_READY: - (void)sprintf(rqsbuf, "Progress Indicator: %d", + (void)snprintf(rqsbuf, sizeof(rqsbuf), + "Progress Indicator: %d", (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff)); return (rqsbuf); default: diff --git a/sys/dev/scsipi/ss_scanjet.c b/sys/dev/scsipi/ss_scanjet.c index 517a0198c08..474463ae608 100644 --- a/sys/dev/scsipi/ss_scanjet.c +++ b/sys/dev/scsipi/ss_scanjet.c @@ -1,4 +1,4 @@ -/* $NetBSD: ss_scanjet.c,v 1.28 2002/09/14 21:41:24 chs Exp $ */ +/* $NetBSD: ss_scanjet.c,v 1.29 2004/04/22 00:17:13 itojun Exp $ */ /* * Copyright (c) 1995 Kenneth Stailey. All rights reserved. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ss_scanjet.c,v 1.28 2002/09/14 21:41:24 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ss_scanjet.c,v 1.29 2004/04/22 00:17:13 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -251,7 +251,7 @@ scanjet_trigger_scanner(ss) } /* send "trigger" operation */ - strcpy(escape_codes, "\033*f0S"); + strlcpy(escape_codes, "\033*f0S", sizeof(escape_codes)); error = scanjet_ctl_write(ss, escape_codes, strlen(escape_codes)); if (error) { uprintf("%s: trigger_scanner failed\n", ss->sc_dev.dv_xname); @@ -376,62 +376,63 @@ int scanjet_set_window(ss) struct ss_softc *ss; { - char escape_codes[128], *p; + char escape_codes[128], *p, *ep; p = escape_codes; - - p += sprintf(p, "\033*f%ldP", ss->sio.scan_width / 4); - p += sprintf(p, "\033*f%ldQ", ss->sio.scan_height / 4); - p += sprintf(p, "\033*f%ldX", ss->sio.scan_x_origin / 4); - p += sprintf(p, "\033*f%ldY", ss->sio.scan_y_origin / 4); - p += sprintf(p, "\033*a%dR", ss->sio.scan_x_resolution); - p += sprintf(p, "\033*a%dS", ss->sio.scan_y_resolution); + ep = &escape_codes[128]; + + p += snprintf(p, ep - p, "\033*f%ldP", ss->sio.scan_width / 4); + p += snprintf(p, ep - p, "\033*f%ldQ", ss->sio.scan_height / 4); + p += snprintf(p, ep - p, "\033*f%ldX", ss->sio.scan_x_origin / 4); + p += snprintf(p, ep - p, "\033*f%ldY", ss->sio.scan_y_origin / 4); + p += snprintf(p, ep - p, "\033*a%dR", ss->sio.scan_x_resolution); + p += snprintf(p, ep - p, "\033*a%dS", ss->sio.scan_y_resolution); switch (ss->sio.scan_image_mode) { case SIM_BINARY_MONOCHROME: ss->sio.scan_bits_per_pixel = 1; /* use "line art" mode */ - strcpy(p, "\033*a0T"); + strlcpy(p, "\033*a0T", ep - p); p += strlen(p); /* make image data be "min-is-white ala PBM */ - strcpy(p, "\033*a0I"); + strlcpy(p, "\033*a0I", ep - p); p += strlen(p); break; case SIM_DITHERED_MONOCHROME: ss->sio.scan_bits_per_pixel = 1; /* use dithered mode */ - strcpy(p, "\033*a3T"); + strlcpy(p, "\033*a3T", ep - p); p += strlen(p); /* make image data be "min-is-white ala PBM */ - strcpy(p, "\033*a0I"); + strlcpy(p, "\033*a0I", ep - p); p += strlen(p); break; case SIM_GRAYSCALE: ss->sio.scan_bits_per_pixel = 8; /* use grayscale mode */ - strcpy(p, "\033*a4T"); + strlcpy(p, "\033*a4T", ep - p); p += strlen(p); /* make image data be "min-is-black ala PGM */ - strcpy(p, "\033*a1I"); + strlcpy(p, "\033*a1I", ep - p); p += strlen(p); break; case SIM_COLOR: ss->sio.scan_bits_per_pixel = 24; /* use RGB color mode */ - strcpy(p, "\033*a5T"); + strlcpy(p, "\033*a5T", ep - p); p += strlen(p); /* make image data be "min-is-black ala PPM */ - strcpy(p, "\033*a1I"); + strlcpy(p, "\033*a1I", ep - p); p += strlen(p); /* use pass-through matrix (disable NTSC) */ - strcpy(p, "\033*u2T"); + strlcpy(p, "\033*u2T", ep - p); p += strlen(p); break; } - p += sprintf(p, "\033*a%dG", ss->sio.scan_bits_per_pixel); - p += sprintf(p, "\033*a%dL", (int)(ss->sio.scan_brightness) - 128); - p += sprintf(p, "\033*a%dK", (int)(ss->sio.scan_contrast) - 128); + p += snprintf(p, ep - p, "\033*a%dG", ss->sio.scan_bits_per_pixel); + p += snprintf(p, ep - p, "\033*a%dL", (int)(ss->sio.scan_brightness) - 128); + p += snprintf(p, ep - p, "\033*a%dK", (int)(ss->sio.scan_contrast) - 128); return (scanjet_ctl_write(ss, escape_codes, p - escape_codes)); } @@ -459,11 +460,13 @@ scanjet_compute_sizes(ss) switch (ss->sio.scan_image_mode) { case SIM_BINARY_MONOCHROME: case SIM_DITHERED_MONOCHROME: - strcpy(escape_codes, "\033*s1025E"); /* bytes wide */ + /* bytes wide */ + strlcpy(escape_codes, "\033*s1025E", sizeof(escape_codes)); break; case SIM_GRAYSCALE: case SIM_COLOR: - strcpy(escape_codes, "\033*s1024E"); /* pixels wide */ + /* pixels wide */ + strlcpy(escape_codes, "\033*s1024E", sizeof(escape_codes)); break; } error = scanjet_ctl_write(ss, escape_codes, strlen(escape_codes)); @@ -485,7 +488,8 @@ scanjet_compute_sizes(ss) if (ss->sio.scan_image_mode < SIM_GRAYSCALE) ss->sio.scan_pixels_per_line *= 8; - strcpy(escape_codes, "\033*s1026E"); /* pixels high */ + /* pixels high */ + strlcpy(escape_codes, "\033*s1026E", sizeof(escape_codes)); error = scanjet_ctl_write(ss, escape_codes, strlen(escape_codes)); if (error) { uprintf(wfail, ss->sc_dev.dv_xname); diff --git a/sys/dev/sun/kbd.c b/sys/dev/sun/kbd.c index 85f3f3de8b0..5cc76fbf641 100644 --- a/sys/dev/sun/kbd.c +++ b/sys/dev/sun/kbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: kbd.c,v 1.39 2003/09/21 19:16:56 jdolecek Exp $ */ +/* $NetBSD: kbd.c,v 1.40 2004/04/22 00:17:13 itojun Exp $ */ /* * Copyright (c) 1992, 1993 @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.39 2003/09/21 19:16:56 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.40 2004/04/22 00:17:13 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -771,7 +771,7 @@ kbd_input_funckey(k, keysym) char str[12]; n = 0xC0 + (keysym & 0x3F); - sprintf(str, "\033[%dz", n); + snprintf(str, sizeof(str), "\033[%dz", n); kbd_input_string(k, str); } diff --git a/sys/dev/tc/tc.c b/sys/dev/tc/tc.c index 139642132b2..3f152f032ee 100644 --- a/sys/dev/tc/tc.c +++ b/sys/dev/tc/tc.c @@ -1,4 +1,4 @@ -/* $NetBSD: tc.c,v 1.36 2003/09/26 17:17:47 tsutsui Exp $ */ +/* $NetBSD: tc.c,v 1.37 2004/04/22 00:17:13 itojun Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tc.c,v 1.36 2003/09/26 17:17:47 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tc.c,v 1.37 2004/04/22 00:17:13 itojun Exp $"); #include "opt_tcverbose.h" @@ -53,7 +53,7 @@ extern struct cfdriver tc_cd; int tcprint __P((void *, const char *)); int tcsubmatch __P((struct device *, struct cfdata *, void *)); int tc_checkslot __P((tc_addr_t, char *)); -void tc_devinfo __P((const char *, char *)); +void tc_devinfo __P((const char *, char *, size_t)); int tcmatch(parent, cf, aux) @@ -190,7 +190,7 @@ tcprint(aux, pnp) char devinfo[256]; if (pnp) { - tc_devinfo(ta->ta_modname, devinfo); + tc_devinfo(ta->ta_modname, devinfo, sizeof(devinfo)); aprint_normal("%s at %s", devinfo, pnp); } aprint_normal(" slot %d offset 0x%x", ta->ta_slot, ta->ta_offset); @@ -304,9 +304,10 @@ struct tc_knowndev { #endif /* TCVERBOSE */ void -tc_devinfo(id, cp) +tc_devinfo(id, cp, l) const char *id; char *cp; + size_t l; { const char *driver, *description; #ifdef TCVERBOSE @@ -336,7 +337,7 @@ tc_devinfo(id, cp) #endif if (driver == NULL) - cp += sprintf(cp, "%sdevice %s", unmatched, id); + snprintf(cp, l, "%sdevice %s", unmatched, id); else - cp += sprintf(cp, "%s (%s)", driver, description); + snprintf(cp, l, "%s (%s)", driver, description); } diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index b5b2ea9cb0f..5dbac207d24 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $NetBSD: uaudio.c,v 1.69 2003/10/14 13:12:19 wiz Exp $ */ +/* $NetBSD: uaudio.c,v 1.70 2004/04/22 00:17:13 itojun Exp $ */ /* * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.69 2003/10/14 13:12:19 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.70 2004/04/22 00:17:13 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -630,7 +630,7 @@ char * uaudio_id_name(struct uaudio_softc *sc, usb_descriptor_t **dps, int id) { static char buf[32]; - sprintf(buf, "i%d", id); + snprintf(buf, sizeof(buf), "i%d", id); return (buf); } @@ -781,8 +781,9 @@ uaudio_add_mixer(struct uaudio_softc *sc, usb_descriptor_t *v, mix.wValue[k++] = MAKE(p+c+1, o+1); } - sprintf(mix.ctlname, "mix%d-%s", d->bUnitId, - uaudio_id_name(sc, dps, d->baSourceId[i])); + snprintf(mix.ctlname, sizeof(mix.ctlname), "mix%d-%s", + d->bUnitId, uaudio_id_name(sc, dps, + d->baSourceId[i])); mix.nchan = chs; uaudio_mixer_add_ctl(sc, &mix); } else { @@ -865,70 +866,70 @@ uaudio_add_feature(struct uaudio_softc *sc, usb_descriptor_t *v, mix.type = MIX_ON_OFF; mix.ctlunit = ""; uaudio_mixer_alias_ctl(sc, &mix, AudioNmute); - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNmute); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNmute); break; case VOLUME_CONTROL: mix.type = MIX_SIGNED_16; mix.ctlunit = AudioNvolume; uaudio_mixer_alias_ctl(sc, &mix, AudioNmaster); - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNmaster); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNmaster); break; case BASS_CONTROL: mix.type = MIX_SIGNED_8; mix.ctlunit = AudioNbass; uaudio_mixer_alias_ctl(sc, &mix, AudioNbass); - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNbass); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNbass); break; case MID_CONTROL: mix.type = MIX_SIGNED_8; mix.ctlunit = AudioNmid; - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNmid); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNmid); break; case TREBLE_CONTROL: mix.type = MIX_SIGNED_8; mix.ctlunit = AudioNtreble; uaudio_mixer_alias_ctl(sc, &mix, AudioNtreble); - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNtreble); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNtreble); break; case GRAPHIC_EQUALIZER_CONTROL: continue; /* XXX don't add anything */ break; case AGC_CONTROL: mix.type = MIX_ON_OFF; - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNagc); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNagc); mix.ctlunit = ""; break; case DELAY_CONTROL: mix.type = MIX_UNSIGNED_16; - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNdelay); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNdelay); mix.ctlunit = "4 ms"; break; case BASS_BOOST_CONTROL: mix.type = MIX_ON_OFF; - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNbassboost); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNbassboost); mix.ctlunit = ""; break; case LOUDNESS_CONTROL: mix.type = MIX_ON_OFF; - sprintf(mix.ctlname, "fea%d-%s-%s", unit, - uaudio_id_name(sc, dps, srcId), - AudioNloudness); + snprintf(mix.ctlname, sizeof(mix.ctlname), + "fea%d-%s-%s", unit, uaudio_id_name(sc, dps, srcId), + AudioNloudness); mix.ctlunit = ""; break; } @@ -964,7 +965,7 @@ uaudio_add_processing_updown(struct uaudio_softc *sc, usb_descriptor_t *v, mix.class = -1; mix.type = MIX_ON_OFF; /* XXX */ mix.ctlunit = ""; - sprintf(mix.ctlname, "pro%d-mode", d->bUnitId); + snprintf(mix.ctlname, sizeof(mix.ctlname), "pro%d-mode", d->bUnitId); for (i = 0; i < ud->bNrModes; i++) { DPRINTFN(2,("uaudio_add_processing_updown: i=%d bm=0x%x\n", @@ -995,7 +996,8 @@ uaudio_add_processing(struct uaudio_softc *sc, usb_descriptor_t *v, mix.class = -1; mix.type = MIX_ON_OFF; mix.ctlunit = ""; - sprintf(mix.ctlname, "pro%d.%d-enable", d->bUnitId, ptype); + snprintf(mix.ctlname, sizeof(mix.ctlname), "pro%d.%d-enable", + d->bUnitId, ptype); uaudio_mixer_add_ctl(sc, &mix); } @@ -1040,7 +1042,8 @@ uaudio_add_extension(struct uaudio_softc *sc, usb_descriptor_t *v, mix.class = -1; mix.type = MIX_ON_OFF; mix.ctlunit = ""; - sprintf(mix.ctlname, "ext%d-enable", d->bUnitId); + snprintf(mix.ctlname, sizeof(mix.ctlname), "ext%d-enable", + d->bUnitId); uaudio_mixer_add_ctl(sc, &mix); } } diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c index f0de500b570..ddfa85000fb 100644 --- a/sys/dev/usb/umass.c +++ b/sys/dev/usb/umass.c @@ -1,4 +1,4 @@ -/* $NetBSD: umass.c,v 1.109 2003/12/04 13:57:31 keihan Exp $ */ +/* $NetBSD: umass.c,v 1.110 2004/04/22 00:17:13 itojun Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -131,7 +131,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.109 2003/12/04 13:57:31 keihan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.110 2004/04/22 00:17:13 itojun Exp $"); #include "atapibus.h" #include "scsibus.h" @@ -1822,7 +1822,7 @@ umass_dump_buffer(struct umass_softc *sc, u_int8_t *buffer, int buflen, s1[0] = '\0'; s3[0] = '\0'; - sprintf(s2, " buffer=%p, buflen=%d", buffer, buflen); + snprintf(s2, sizeof(s2), " buffer=%p, buflen=%d", buffer, buflen); for (i = 0; i < buflen && i < printlen; i++) { j = i % 16; if (j == 0 && i != 0) { @@ -1830,10 +1830,11 @@ umass_dump_buffer(struct umass_softc *sc, u_int8_t *buffer, int buflen, USBDEVNAME(sc->sc_dev), s1, s2)); s2[0] = '\0'; } - sprintf(&s1[j*2], "%02x", buffer[i] & 0xff); + snprintf(&s1[j * 2], sizeof(s1) - j * 2, "%02x", + buffer[i] & 0xff); } if (buflen > printlen) - sprintf(s3, " ..."); + snprintf(s3, sizeof(s3), " ..."); DPRINTF(UDMASS_GEN, ("%s: 0x %s%s%s\n", USBDEVNAME(sc->sc_dev), s1, s2, s3)); } diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index bd3b5c52201..f895b403d27 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.111 2004/03/15 10:35:04 augustss Exp $ */ +/* $NetBSD: usb_subr.c,v 1.112 2004/04/22 00:17:14 itojun Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.111 2004/03/15 10:35:04 augustss Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.112 2004/04/22 00:17:14 itojun Exp $"); #include "opt_usbverbose.h" @@ -81,7 +81,8 @@ extern int usbdebug; #endif Static usbd_status usbd_set_config(usbd_device_handle, int); -Static void usbd_devinfo_vp(usbd_device_handle, char *, char *, int); +Static void usbd_devinfo_vp(usbd_device_handle, char *, size_t, char *, + size_t, int); Static char *usbd_get_string(usbd_device_handle, int, char *); Static int usbd_getnewaddr(usbd_bus_handle bus); #if defined(__NetBSD__) @@ -237,7 +238,8 @@ usbd_trim_spaces(char *p) } void -usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p, int usedev) +usbd_devinfo_vp(usbd_device_handle dev, char *v, size_t lv, char *p, size_t lp, + int usedev) { usb_device_descriptor_t *udd = &dev->ddesc; char *vendor = NULL, *product = NULL; @@ -283,13 +285,13 @@ usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p, int usedev) } #endif if (vendor != NULL && *vendor) - strcpy(v, vendor); + strlcpy(v, vendor, lv); else - sprintf(v, "vendor 0x%04x", UGETW(udd->idVendor)); + snprintf(v, lv, "vendor 0x%04x", UGETW(udd->idVendor)); if (product != NULL && *product) - strcpy(p, product); + strlcpy(p, product, lp); else - sprintf(p, "product 0x%04x", UGETW(udd->idProduct)); + snprintf(p, lp, "product 0x%04x", UGETW(udd->idProduct)); } int @@ -298,6 +300,7 @@ usbd_printBCD(char *cp, int bcd) return (sprintf(cp, "%x.%02x", bcd >> 8, bcd & 0xff)); } +/* XXX cp not bounded */ void usbd_devinfo(usbd_device_handle dev, int showclass, char *cp) { @@ -306,7 +309,8 @@ usbd_devinfo(usbd_device_handle dev, int showclass, char *cp) char product[USB_MAX_STRING_LEN]; int bcdDevice, bcdUSB; - usbd_devinfo_vp(dev, vendor, product, 1); + usbd_devinfo_vp(dev, vendor, sizeof(vendor), product, + sizeof(product), 1); cp += sprintf(cp, "%s %s", vendor, product); if (showclass) cp += sprintf(cp, ", class %d/%d", @@ -1265,7 +1269,8 @@ usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di, di->udi_bus = USBDEVUNIT(dev->bus->bdev); di->udi_addr = dev->address; di->udi_cookie = dev->cookie; - usbd_devinfo_vp(dev, di->udi_vendor, di->udi_product, usedev); + usbd_devinfo_vp(dev, di->udi_vendor, sizeof(di->udi_vendor), + di->udi_product, sizeof(di->udi_product), usedev); usbd_printBCD(di->udi_release, UGETW(dev->ddesc.bcdDevice)); di->udi_vendorNo = UGETW(dev->ddesc.idVendor); di->udi_productNo = UGETW(dev->ddesc.idProduct); |
