diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2003-04-27 11:22:55 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2003-04-27 11:22:55 +0000 |
commit | c670c56d6bb9915caf18009083d3515283a25fe1 (patch) | |
tree | ffee78ad4ad468acbebd70d511be258d28fdbd52 | |
parent | c9c7d16545b1bfad4519f491aa113a57ab7c7b2d (diff) |
strcpy/sprintf cleanup of sys/dev. miod@, deraadt@ says to commit.
81 files changed, 1176 insertions, 883 deletions
diff --git a/sys/arch/i386/pci/pci_intr_fixup.c b/sys/arch/i386/pci/pci_intr_fixup.c index 465d1bec5c8..3df5b0600eb 100644 --- a/sys/arch/i386/pci/pci_intr_fixup.c +++ b/sys/arch/i386/pci/pci_intr_fixup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_intr_fixup.c,v 1.24 2002/05/30 15:52:09 mickey Exp $ */ +/* $OpenBSD: pci_intr_fixup.c,v 1.25 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: pci_intr_fixup.c,v 1.10 2000/08/10 21:18:27 soda Exp $ */ /* @@ -805,7 +805,8 @@ pci_intr_fixup(sc, pc, iot) PIR_DEVFUNC_DEVICE(pirh->router_devfunc), PIR_DEVFUNC_FUNCTION(pirh->router_devfunc)); if (pirh->compat_router != 0) { - pci_devinfo(pirh->compat_router, 0, 0, devinfo); + pci_devinfo(pirh->compat_router, 0, 0, devinfo, + sizeof devinfo); printf(" (%s)", devinfo); } printf("\n"); diff --git a/sys/arch/macppc/pci/pchb.c b/sys/arch/macppc/pci/pchb.c index 8631e1d78e8..b758aada142 100644 --- a/sys/arch/macppc/pci/pchb.c +++ b/sys/arch/macppc/pci/pchb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pchb.c,v 1.4 2002/07/29 19:55:56 drahn Exp $ */ +/* $OpenBSD: pchb.c,v 1.5 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: pchb.c,v 1.4 2000/01/25 07:19:11 tsubai Exp $ */ /*- @@ -117,7 +117,7 @@ pchbattach(parent, self, aux) */ /* - pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof devinfo); printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo, PCI_REVISION(pa->pa_class)); */ diff --git a/sys/arch/mvmeppc/pci/pchb.c b/sys/arch/mvmeppc/pci/pchb.c index a592a3a0982..dd5964f9d84 100644 --- a/sys/arch/mvmeppc/pci/pchb.c +++ b/sys/arch/mvmeppc/pci/pchb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pchb.c,v 1.4 2002/03/14 01:26:41 millert Exp $ */ +/* $OpenBSD: pchb.c,v 1.5 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: pchb.c,v 1.4 2000/01/25 07:19:11 tsubai Exp $ */ /*- @@ -102,7 +102,7 @@ pchbattach(parent, self, aux) */ /* - pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof devinfo); printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo, PCI_REVISION(pa->pa_class)); */ diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 81e40c95588..601a420b5f8 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cardbus.c,v 1.6 2002/03/14 03:16:04 millert Exp $ */ +/* $OpenBSD: cardbus.c,v 1.7 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: cardbus.c,v 1.24 2000/04/02 19:11:37 mycroft Exp $ */ /* @@ -574,7 +574,7 @@ cardbusprint(aux, pnp) char devinfo[256]; int i; if (pnp) { - pci_devinfo(ca->ca_id, ca->ca_class, 1, devinfo); + pci_devinfo(ca->ca_id, ca->ca_class, 1, devinfo, sizeof devinfo); for (i = 0; i < 4; i++) { if (ca->ca_cis.cis1_info[i] == NULL) break; diff --git a/sys/dev/cardbus/fwohci_cardbus.c b/sys/dev/cardbus/fwohci_cardbus.c index d74077473b7..0c33697e535 100644 --- a/sys/dev/cardbus/fwohci_cardbus.c +++ b/sys/dev/cardbus/fwohci_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fwohci_cardbus.c,v 1.3 2002/12/13 02:15:01 tdeval Exp $ */ +/* $OpenBSD: fwohci_cardbus.c,v 1.4 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: fwohci_cardbus.c,v 1.5 2002/01/26 16:34:28 ichiro Exp $ */ /* @@ -122,7 +122,7 @@ fwohci_cardbus_attach(struct device *parent, struct device *self, void *aux) char devinfo[256]; const char *devname = self->dv_xname; - cardbus_devinfo(ca->ca_id, ca->ca_class, 0, devinfo); + cardbus_devinfo(ca->ca_id, ca->ca_class, 0, devinfo, sizeof devinfo); printf(": %s (rev. 0x%02x)\n", devinfo, CARDBUS_REVISION(ca->ca_class)); diff --git a/sys/dev/eisa/eisa.c b/sys/dev/eisa/eisa.c index cf96399d40c..fb2c03a441f 100644 --- a/sys/dev/eisa/eisa.c +++ b/sys/dev/eisa/eisa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eisa.c,v 1.10 2003/03/29 00:17:44 mickey Exp $ */ +/* $OpenBSD: eisa.c,v 1.11 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: eisa.c,v 1.15 1996/10/21 22:31:01 thorpej Exp $ */ /* @@ -62,7 +62,7 @@ struct cfdriver eisa_cd = { int eisasubmatch(struct device *, void *, void *); int eisaprint(void *, const char *); -void eisa_devinfo(const char *, char *); +void eisa_devinfo(const char *, char *, size_t); int eisamatch(parent, match, aux) @@ -89,7 +89,7 @@ eisaprint(aux, pnp) char devinfo[256]; if (pnp) { - eisa_devinfo(ea->ea_idstring, devinfo); + eisa_devinfo(ea->ea_idstring, devinfo, sizeof devinfo); printf("%s at %s", devinfo, pnp); } printf(" slot %d", ea->ea_slot); @@ -231,9 +231,7 @@ struct eisa_knowndev { #endif /* EISAVERBOSE */ void -eisa_devinfo(id, cp) - const char *id; - char *cp; +eisa_devinfo(const char *id, char *cp, size_t cp_len) { const char *name; int onlyvendor; @@ -267,9 +265,9 @@ eisa_devinfo(id, cp) #endif if (name == NULL) - cp += sprintf(cp, "%sdevice %s", unmatched, id); + snprintf(cp, cp_len, "%sdevice %s", unmatched, id); else if (onlyvendor) /* never if not EISAVERBOSE */ - cp += sprintf(cp, "unknown %s device %s", name, id); + snprintf(cp, cp_len, "unknown %s device %s", name, id); else - cp += sprintf(cp, "%s", name); + snprintf(cp, cp_len, "%s", name); } diff --git a/sys/dev/i2o/iop.c b/sys/dev/i2o/iop.c index ca99d150ec9..f0b8bf8f2ce 100644 --- a/sys/dev/i2o/iop.c +++ b/sys/dev/i2o/iop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iop.c,v 1.22 2002/06/07 09:10:13 nordin Exp $ */ +/* $OpenBSD: iop.c,v 1.23 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: iop.c,v 1.12 2001/03/21 14:27:05 ad Exp $ */ /*- @@ -208,7 +208,7 @@ static inline void iop_outl(struct iop_softc *, int, u_int32_t); void iop_config_interrupts(struct device *); void iop_configure_devices(struct iop_softc *, int, int); -void iop_devinfo(int, char *); +void iop_devinfo(int, char *, size_t); int iop_print(void *, const char *); int iop_reconfigure(struct iop_softc *, u_int); void iop_shutdown(void *); @@ -781,8 +781,9 @@ iop_configure_devices(struct iop_softc *sc, int mask, int maskval) LIST_FOREACH(ii, &sc->sc_iilist, ii_list) { if (ia.ia_tid == ii->ii_tid) { sc->sc_tidmap[i].it_flags |= IT_CONFIGURED; - strcpy(sc->sc_tidmap[i].it_dvname, - ii->ii_dv->dv_xname); + strlcpy(sc->sc_tidmap[i].it_dvname, + ii->ii_dv->dv_xname, + sizeof sc->sc_tidmap[i].it_dvname); break; } } @@ -791,7 +792,8 @@ iop_configure_devices(struct iop_softc *sc, int mask, int maskval) dv = config_found_sm(&sc->sc_dv, &ia, iop_print, iop_submatch); if (dv != NULL) { sc->sc_tidmap[i].it_flags |= IT_CONFIGURED; - strcpy(sc->sc_tidmap[i].it_dvname, dv->dv_xname); + strlcpy(sc->sc_tidmap[i].it_dvname, dv->dv_xname, + sizeof sc->sc_tidmap[i].it_dvname); } } } @@ -810,7 +812,7 @@ iop_adjqparam(struct iop_softc *sc, int mpi) } void -iop_devinfo(int class, char *devinfo) +iop_devinfo(int class, char *devinfo, size_t di_len) { #ifdef I2OVERBOSE int i; @@ -820,12 +822,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, di_len, "device (class 0x%x)", class); else - strcpy(devinfo, iop_class[i].ic_caption); + strlcpy(devinfo, iop_class[i].ic_caption, di_len); #else - sprintf(devinfo, "device (class 0x%x)", class); + snprintf(devinfo, di_len, "device (class 0x%x)", class); #endif } @@ -838,7 +840,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); printf("%s at %s", devinfo, pnp); } printf(" tid %d", ia->ia_tid); diff --git a/sys/dev/i2o/ioprbs.c b/sys/dev/i2o/ioprbs.c index 16944297648..4c62cb0143f 100644 --- a/sys/dev/i2o/ioprbs.c +++ b/sys/dev/i2o/ioprbs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ioprbs.c,v 1.3 2002/04/03 16:47:57 niklas Exp $ */ +/* $OpenBSD: ioprbs.c,v 1.4 2003/04/27 11:22:52 ho Exp $ */ /* * Copyright (c) 2001 Niklas Hallqvist @@ -785,9 +785,10 @@ ioprbs_internal_cache_cmd(xs) inq.version = 2; inq.response_format = 2; inq.additional_length = 32; - strcpy(inq.vendor, "I2O"); - sprintf(inq.product, "Container #%02d", target); - strcpy(inq.revision, " "); + strlcpy(inq.vendor, "I2O", sizeof inq.vendor); + snprintf(inq.product, sizeof inq.product, "Container #%02d", + target); + strlcpy(inq.revision, " ", sizeof inq.revision); ioprbs_copy_internal_data(xs, (u_int8_t *)&inq, sizeof inq); break; diff --git a/sys/dev/ic/aac.c b/sys/dev/ic/aac.c index abdfe81fbb1..40f45b6f1e4 100644 --- a/sys/dev/ic/aac.c +++ b/sys/dev/ic/aac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aac.c,v 1.14 2002/03/27 15:02:59 niklas Exp $ */ +/* $OpenBSD: aac.c,v 1.15 2003/04/27 11:22:52 ho Exp $ */ /*- * Copyright (c) 2000 Michael Smith @@ -848,9 +848,10 @@ aac_internal_cache_cmd(xs) inq.version = 2; inq.response_format = 2; inq.additional_length = 32; - strcpy(inq.vendor, "Adaptec"); - sprintf(inq.product, "Container #%02d", target); - strcpy(inq.revision, " "); + strlcpy(inq.vendor, "Adaptec", sizeof inq.vendor); + snprintf(inq.product, sizeof inq.product, "Container #%02d", + target); + strlcpy(inq.revision, " ", sizeof inq.revision); aac_copy_internal_data(xs, (u_int8_t *)&inq, sizeof inq); break; diff --git a/sys/dev/ic/ac97.c b/sys/dev/ic/ac97.c index d4e5553234c..0dcc07bb644 100644 --- a/sys/dev/ic/ac97.c +++ b/sys/dev/ic/ac97.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ac97.c,v 1.35 2003/04/09 20:05:47 mickey Exp $ */ +/* $OpenBSD: ac97.c,v 1.36 2003/04/27 11:22:52 ho Exp $ */ /* * Copyright (c) 1999, 2000 Constantine Sapuntzakis @@ -778,7 +778,7 @@ ac97_query_devinfo(codec_if, dip) name = si->class; if (name) - strcpy(dip->label.name, name); + strlcpy(dip->label.name, name, sizeof dip->label.name); bcopy(si->info, &dip->un, si->info_size); diff --git a/sys/dev/ic/aic7xxx.c b/sys/dev/ic/aic7xxx.c index 98c16e4479e..589c0273b80 100644 --- a/sys/dev/ic/aic7xxx.c +++ b/sys/dev/ic/aic7xxx.c @@ -28,10 +28,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: aic7xxx.c,v 1.46 2003/03/30 21:04:18 krw Exp $ + * $Id: aic7xxx.c,v 1.47 2003/04/27 11:22:52 ho Exp $ * * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.80 2001/12/16 17:38:30 gibbs Exp $ - * $OpenBSD: aic7xxx.c,v 1.46 2003/03/30 21:04:18 krw Exp $ + * $OpenBSD: aic7xxx.c,v 1.47 2003/04/27 11:22:52 ho Exp $ */ #ifdef __OpenBSD__ @@ -4148,17 +4148,18 @@ ahc_alloc_scbs(struct ahc_softc *ahc) #endif /* __OpenBSD__ */ void -ahc_controller_info(struct ahc_softc *ahc, char *buf) +ahc_controller_info(struct ahc_softc *ahc, char *buf, size_t buf_len) { - int len; + int len = 0; - len = sprintf(buf, "%s: ", ahc_chip_names[ahc->chip & AHC_CHIPID_MASK]); - buf += len; + snprintf(buf + len, buf_len - len, "%s: ", + ahc_chip_names[ahc->chip & AHC_CHIPID_MASK]); + len = strlen(buf); if ((ahc->features & AHC_TWIN) != 0) - len = sprintf(buf, "Twin Channel, A SCSI Id=%d, " - "B SCSI Id=%d, primary %c, ", - ahc->our_id, ahc->our_id_b, - (ahc->flags & AHC_PRIMARY_CHANNEL) + 'A'); + snprintf(buf + len, buf_len - len, + "Twin Channel, A SCSI Id=%d, B SCSI Id=%d, " + "primary %c, ", ahc->our_id, ahc->our_id_b, + (ahc->flags & AHC_PRIMARY_CHANNEL) + 'A'); else { const char *speed; const char *type; @@ -4176,16 +4177,18 @@ ahc_controller_info(struct ahc_softc *ahc, char *buf) } else { type = "Single"; } - len = sprintf(buf, "%s%s Channel %c, SCSI Id=%d, ", - speed, type, ahc->channel, ahc->our_id); + snprintf(buf + len, buf_len - len, + "%s%s Channel %c, SCSI Id=%d, ", + speed, type, ahc->channel, ahc->our_id); } - buf += len; + len = strlen(buf); if ((ahc->flags & AHC_PAGESCBS) != 0) - sprintf(buf, "%d/%d SCBs", - ahc->scb_data->maxhscbs, AHC_SCB_MAX); + snprintf(buf + len, buf_len - len, "%d/%d SCBs", + ahc->scb_data->maxhscbs, AHC_SCB_MAX); else - sprintf(buf, "%d SCBs", ahc->scb_data->maxhscbs); + snprintf(buf + len, buf_len - len, "%d SCBs", + ahc->scb_data->maxhscbs); } /* diff --git a/sys/dev/ic/aic7xxx.h b/sys/dev/ic/aic7xxx.h index a9b1636a567..9a689e2c205 100644 --- a/sys/dev/ic/aic7xxx.h +++ b/sys/dev/ic/aic7xxx.h @@ -1,5 +1,5 @@ /* - * $OpenBSD: aic7xxx.h,v 1.6 2003/01/06 11:33:28 miod Exp $ + * $OpenBSD: aic7xxx.h,v 1.7 2003/04/27 11:22:52 ho Exp $ * Core definitions and data structures shareable across OS platforms. * * Copyright (c) 1994-2001 Justin T. Gibbs. @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: aic7xxx.h,v 1.6 2003/01/06 11:33:28 miod Exp $ + * $Id: aic7xxx.h,v 1.7 2003/04/27 11:22:52 ho Exp $ * * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.h,v 1.40 2001/07/18 21:39:47 gibbs Exp $ */ @@ -1101,7 +1101,8 @@ int ahc_match_scb(struct ahc_softc *ahc, struct scb *scb, /****************************** Initialization ********************************/ struct ahc_softc *ahc_alloc(void *platform_arg, char *name); int ahc_softc_init(struct ahc_softc *); -void ahc_controller_info(struct ahc_softc *ahc, char *buf); +void ahc_controller_info(struct ahc_softc *ahc, char *buf, + size_t buf_len); int ahc_init(struct ahc_softc *ahc); void ahc_intr_enable(struct ahc_softc *ahc, int enable); void ahc_pause_and_flushwork(struct ahc_softc *ahc); diff --git a/sys/dev/ic/aic7xxx_openbsd.c b/sys/dev/ic/aic7xxx_openbsd.c index 5afa40c1721..d50625b61ff 100644 --- a/sys/dev/ic/aic7xxx_openbsd.c +++ b/sys/dev/ic/aic7xxx_openbsd.c @@ -29,10 +29,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: aic7xxx_openbsd.c,v 1.11 2003/03/21 14:58:06 drahn Exp $ + * $Id: aic7xxx_openbsd.c,v 1.12 2003/04/27 11:22:52 ho Exp $ * * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_freebsd.c,v 1.26 2001/07/18 21:39:47 gibbs Exp $ - * $OpenBSD: aic7xxx_openbsd.c,v 1.11 2003/03/21 14:58:06 drahn Exp $ + * $OpenBSD: aic7xxx_openbsd.c,v 1.12 2003/04/27 11:22:52 ho Exp $ */ #include <dev/ic/aic7xxx_openbsd.h> @@ -513,7 +513,7 @@ ahc_attach(ahc) int s; ahc_lock(ahc, &s); - ahc_controller_info(ahc, ahc_info); + ahc_controller_info(ahc, ahc_info, sizeof ahc_info); printf("%s: %s\n", ahc_name(ahc), ahc_info); /* * Initialize the software queue. diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c index a877fd414e8..c8910b38b49 100644 --- a/sys/dev/ic/ami.c +++ b/sys/dev/ic/ami.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ami.c,v 1.20 2003/02/25 00:26:08 tedu Exp $ */ +/* $OpenBSD: ami.c,v 1.21 2003/04/27 11:22:52 ho Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -432,10 +432,10 @@ ami_attach(sc) 'A' <= sc->sc_biosver[2] && sc->sc_biosver[2] <= 'Z' && sc->sc_biosver[1] < ' ' && sc->sc_biosver[0] < ' ') { - sprintf(sc->sc_fwver, "%c.%02d.%02d", sc->sc_fwver[2], - sc->sc_fwver[1], sc->sc_fwver[0]); - sprintf(sc->sc_biosver, "%c.%02d.%02d", sc->sc_biosver[2], - sc->sc_biosver[1], sc->sc_biosver[0]); + snprintf(sc->sc_fwver, sizeof sc->sc_fwver, "%c.%02d.%02d", + sc->sc_fwver[2], sc->sc_fwver[1], sc->sc_fwver[0]); + snprintf(sc->sc_biosver, sizeof sc->sc_biosver, "%c.%02d.%02d", + sc->sc_biosver[2], sc->sc_biosver[1], sc->sc_biosver[0]); } printf(": FW %s, BIOS v%s, %dMB RAM\n" @@ -1120,9 +1120,10 @@ ami_scsi_cmd(xs) inq.version = 2; inq.response_format = 2; inq.additional_length = 32; - strcpy(inq.vendor, "AMI "); - sprintf(inq.product, "Host drive #%02d", target); - strcpy(inq.revision, " "); + strlcpy(inq.vendor, "AMI ", sizeof inq.vendor); + snprintf(inq.product, sizeof inq.product, "Host drive #%02d", + target); + strlcpy(inq.revision, " ", sizeof inq.revision); ami_copy_internal_data(xs, &inq, sizeof inq); break; diff --git a/sys/dev/ic/awi.c b/sys/dev/ic/awi.c index 245b68677c1..cbaab93411c 100644 --- a/sys/dev/ic/awi.c +++ b/sys/dev/ic/awi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: awi.c,v 1.11 2002/09/15 22:18:11 deraadt Exp $ */ +/* $OpenBSD: awi.c,v 1.12 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: awi.c,v 1.26 2000/07/21 04:48:55 onoe Exp $ */ /*- @@ -261,7 +261,7 @@ ether_sprintf(enaddr) { static char strbuf[18]; - sprintf(strbuf, "%6D", enaddr, ":"); + snprintf(strbuf, sizeof strbuf, "%6D", enaddr, ":"); return strbuf; } #endif diff --git a/sys/dev/ic/bha.c b/sys/dev/ic/bha.c index e621dee35ae..d90dbf5dbc4 100644 --- a/sys/dev/ic/bha.c +++ b/sys/dev/ic/bha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bha.c,v 1.4 2002/06/03 12:04:08 deraadt Exp $ */ +/* $OpenBSD: bha.c,v 1.5 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: bha.c,v 1.27 1998/11/19 21:53:00 thorpej Exp $ */ #undef BHADEBUG @@ -1319,7 +1319,7 @@ bha_inquire_setup_information(sc) p--; *p = '\0'; } else - strcpy(sc->sc_model, "542B"); + strlcpy(sc->sc_model, "542B", sizeof sc->sc_model); } void diff --git a/sys/dev/ic/cac.c b/sys/dev/ic/cac.c index 026f7edd719..c6d178698d5 100644 --- a/sys/dev/ic/cac.c +++ b/sys/dev/ic/cac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cac.c,v 1.13 2003/03/15 19:16:10 deraadt Exp $ */ +/* $OpenBSD: cac.c,v 1.14 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: cac.c,v 1.15 2000/11/08 19:20:35 ad Exp $ */ /* @@ -620,7 +620,7 @@ cac_scsi_cmd(xs) inq.version = 2; inq.response_format = 2; inq.additional_length = 32; - strcpy(inq.vendor, "Compaq "); + strlcpy(inq.vendor, "Compaq ", sizeof inq.vendor); switch (CAC_GET1(dinfo->mirror)) { case 0: p = "RAID0"; break; case 1: p = "RAID4"; break; @@ -628,8 +628,9 @@ cac_scsi_cmd(xs) case 3: p = "RAID5"; break; default:p = "<UNK>"; break; } - sprintf(inq.product, "%s volume #%02d", p, target); - strcpy(inq.revision, " "); + snprintf(inq.product, sizeof inq.product, "%s volume #%02d", + p, target); + strlcpy(inq.revision, " ", sizeof inq.revision); cac_copy_internal_data(xs, &inq, sizeof inq); break; diff --git a/sys/dev/ic/gdt_common.c b/sys/dev/ic/gdt_common.c index cc5fb483ef4..234294b464a 100644 --- a/sys/dev/ic/gdt_common.c +++ b/sys/dev/ic/gdt_common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gdt_common.c,v 1.23 2003/02/25 09:12:39 tedu Exp $ */ +/* $OpenBSD: gdt_common.c,v 1.24 2003/04/27 11:22:52 ho Exp $ */ /* * Copyright (c) 1999, 2000 Niklas Hallqvist. All rights reserved. @@ -893,9 +893,10 @@ gdt_internal_cache_cmd(xs) inq.version = 2; inq.response_format = 2; inq.additional_length = 32; - strcpy(inq.vendor, "ICP "); - sprintf(inq.product, "Host drive #%02d", target); - strcpy(inq.revision, " "); + strlcpy(inq.vendor, "ICP ", sizeof inq.vendor); + snprintf(inq.product, sizeof inq.product, "Host drive #%02d", + target); + strlcpy(inq.revision, " ", sizeof inq.revision); gdt_copy_internal_data(xs, (u_int8_t *)&inq, sizeof inq); break; @@ -1456,7 +1457,7 @@ gdt_ioctl(dev, cmd, addr) p->revision = osrelease[4] - '0'; else p->revision = 0; - strcpy(p->name, ostype); + strlcpy(p->name, ostype, sizeof p->name); break; } diff --git a/sys/dev/ic/gem.c b/sys/dev/ic/gem.c index aeaadbe0446..abea513e749 100644 --- a/sys/dev/ic/gem.c +++ b/sys/dev/ic/gem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gem.c,v 1.31 2003/03/02 02:59:10 henric Exp $ */ +/* $OpenBSD: gem.c,v 1.32 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: gem.c,v 1.1 2001/09/16 00:11:43 eeh Exp $ */ /* @@ -217,7 +217,7 @@ gem_config(sc) bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_RX_FIFO_SIZE); /* Initialize ifnet structure. */ - strcpy(ifp->if_xname, sc->sc_dev.dv_xname); + strlcpy(ifp->if_xname, sc->sc_dev.dv_xname, sizeof ifp->if_xname); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; diff --git a/sys/dev/ic/hme.c b/sys/dev/ic/hme.c index 86521d64012..0d4ee3b2a5f 100644 --- a/sys/dev/ic/hme.c +++ b/sys/dev/ic/hme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hme.c,v 1.27 2003/04/26 08:01:42 jmc Exp $ */ +/* $OpenBSD: hme.c,v 1.28 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $ */ /*- @@ -233,7 +233,7 @@ hme_config(sc) printf(": address %s\n", ether_sprintf(sc->sc_enaddr)); /* Initialize ifnet structure. */ - strcpy(ifp->if_xname, sc->sc_dev.dv_xname); + strlcpy(ifp->if_xname, sc->sc_dev.dv_xname, sizeof ifp->if_xname); ifp->if_softc = sc; ifp->if_start = hme_start; ifp->if_ioctl = hme_ioctl; diff --git a/sys/dev/ic/ncr53c9xvar.h b/sys/dev/ic/ncr53c9xvar.h index 8b9b02f11a4..e731ed08214 100644 --- a/sys/dev/ic/ncr53c9xvar.h +++ b/sys/dev/ic/ncr53c9xvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr53c9xvar.h,v 1.11 2003/02/24 00:41:51 miod Exp $ */ +/* $OpenBSD: ncr53c9xvar.h,v 1.12 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: ncr53c9xvar.h,v 1.13 1998/05/26 23:17:34 thorpej Exp $ */ /*- @@ -138,7 +138,7 @@ struct ncr53c9x_ecb { const char *f = "[" msg "]"; \ int n = strlen((ecb)->trace); \ if (n < (sizeof((ecb)->trace)-100)) \ - sprintf((ecb)->trace + n, f, a, b); \ + snprintf((ecb)->trace + n, sizeof((ecb)->trace) - n, f, a, b); \ } while(0) #else #define ECB_TRACE(ecb, msg, a, b) diff --git a/sys/dev/ic/opl.c b/sys/dev/ic/opl.c index c8c78afa160..13b07da12be 100644 --- a/sys/dev/ic/opl.c +++ b/sys/dev/ic/opl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opl.c,v 1.3 2002/03/14 01:26:55 millert Exp $ */ +/* $OpenBSD: opl.c,v 1.4 2003/04/27 11:22:52 ho Exp $ */ /* $NetBSD: opl.c,v 1.7 1998/12/08 14:26:56 augustss Exp $ */ /* @@ -159,7 +159,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/twe.c b/sys/dev/ic/twe.c index 9d3ba2091c5..cc7bab22a09 100644 --- a/sys/dev/ic/twe.c +++ b/sys/dev/ic/twe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: twe.c,v 1.19 2003/04/09 20:44:57 mickey Exp $ */ +/* $OpenBSD: twe.c,v 1.20 2003/04/27 11:22:52 ho Exp $ */ /* * Copyright (c) 2000-2002 Michael Shalayeff. All rights reserved. @@ -850,9 +850,10 @@ twe_scsi_cmd(xs) inq.version = 2; inq.response_format = 2; inq.additional_length = 32; - strcpy(inq.vendor, "3WARE "); - sprintf(inq.product, "Host drive #%02d", target); - strcpy(inq.revision, " "); + strlcpy(inq.vendor, "3WARE ", sizeof inq.vendor); + snprintf(inq.product, sizeof inq.product, "Host drive #%02d", + target); + strlcpy(inq.revision, " ", sizeof inq.revision); twe_copy_internal_data(xs, &inq, sizeof inq); break; diff --git a/sys/dev/ieee1394/fwohci.c b/sys/dev/ieee1394/fwohci.c index 092c419caef..30b6267853b 100644 --- a/sys/dev/ieee1394/fwohci.c +++ b/sys/dev/ieee1394/fwohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fwohci.c,v 1.12 2003/01/13 07:16:20 tdeval Exp $ */ +/* $OpenBSD: fwohci.c,v 1.13 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: fwohci.c,v 1.54 2002/03/29 05:06:42 jmc Exp $ */ /* @@ -3327,7 +3327,7 @@ fwohci_uid_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *res) } } if (!found) { - strcpy(fwa.name, "fwnode"); + strlcpy(fwa.name, "fwnode", sizeof fwa.name); fwa.link_speed = fu->fu_link_speed; bcopy(fu->fu_uid, fwa.uid, 8); fwa.nodeid = n; diff --git a/sys/dev/isa/ad1848.c b/sys/dev/isa/ad1848.c index da25e4d1e73..0adb6cd76d2 100644 --- a/sys/dev/isa/ad1848.c +++ b/sys/dev/isa/ad1848.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ad1848.c,v 1.27 2003/02/11 19:20:27 mickey Exp $ */ +/* $OpenBSD: ad1848.c,v 1.28 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: ad1848.c,v 1.45 1998/01/30 02:02:38 augustss Exp $ */ /* @@ -943,32 +943,32 @@ ad1848_query_encoding(addr, fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = 0; break; case 1: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = 0; break; case 2: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 3: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; case 4: /* only on CS4231 */ - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = sc->mode == 1 ? AUDIO_ENCODINGFLAG_EMULATED : 0; @@ -976,19 +976,19 @@ ad1848_query_encoding(addr, fp) /* emulate some modes */ case 5: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 6: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -997,7 +997,7 @@ ad1848_query_encoding(addr, fp) case 8: /* only on CS4231 */ if (sc->mode == 1) return EINVAL; - strcpy(fp->name, AudioEadpcm); + strlcpy(fp->name, AudioEadpcm, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ADPCM; fp->precision = 8; fp->flags = 0; diff --git a/sys/dev/isa/aha.c b/sys/dev/isa/aha.c index e8236973c6e..8b288c9cbc4 100644 --- a/sys/dev/isa/aha.c +++ b/sys/dev/isa/aha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aha.c,v 1.50 2003/04/10 10:11:24 miod Exp $ */ +/* $OpenBSD: aha.c,v 1.51 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: aha.c,v 1.11 1996/05/12 23:51:23 mycroft Exp $ */ #undef AHADIAG @@ -1162,7 +1162,7 @@ aha_inquire_setup_information(sc) int i; char *p; - strcpy(sc->sc_model, "unknown"); + strlcpy(sc->sc_model, "unknown", sizeof sc->sc_model); /* * Assume we have a board at this stage, do an adapter inquire @@ -1204,23 +1204,23 @@ aha_inquire_setup_information(sc) switch (revision.reply.boardid) { case 0x31: - strcpy(sc->sc_model, "1540"); + strlcpy(sc->sc_model, "1540", sizeof sc->sc_model); break; case 0x41: - strcpy(sc->sc_model, "1540A/1542A/1542B"); + strlcpy(sc->sc_model, "1540A/1542A/1542B", sizeof sc->sc_model); break; case 0x42: - strcpy(sc->sc_model, "1640"); + strlcpy(sc->sc_model, "1640", sizeof sc->sc_model); break; case 0x43: case 0x44: /* Is this 1542C or -CF? */ - strcpy(sc->sc_model, "1542C"); + strlcpy(sc->sc_model, "1542C", sizeof sc->sc_model); break; case 0x45: - strcpy(sc->sc_model, "1542CF"); + strlcpy(sc->sc_model, "1542CF", sizeof sc->sc_model); break; case 0x46: - strcpy(sc->sc_model, "1542CP"); + strlcpy(sc->sc_model, "1542CP", sizeof sc->sc_model); break; } diff --git a/sys/dev/isa/aria.c b/sys/dev/isa/aria.c index ad23c43ea8c..ad09545920d 100644 --- a/sys/dev/isa/aria.c +++ b/sys/dev/isa/aria.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aria.c,v 1.8 2002/03/14 03:16:05 millert Exp $ */ +/* $OpenBSD: aria.c,v 1.9 2003/04/27 11:22:53 ho Exp $ */ /* * Copyright (c) 1995, 1996 Roland C. Dowdeswell. All rights reserved. @@ -469,7 +469,8 @@ ariaattach(parent, self, aux) printf(", SC18075 mixer"); printf("\n"); - sprintf(aria_device.version, "%s", (ARIA_MODEL&sc->sc_hardware?"SC18026":"SC18025")); + snprintf(aria_device.version, sizeof aria_device.version, "%s", + (ARIA_MODEL&sc->sc_hardware?"SC18026":"SC18025")); if ((err = audio_hardware_attach(&aria_hw_if, sc)) != 0) printf("aria: could not attach to audio pseudo-device driver (%d)\n", err); @@ -582,11 +583,11 @@ aria_query_encoding(addr, fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->format_id = AUDIO_ENCODING_ULAW; break; case 1: - strcpy(fp->name, AudioEpcm16); + strlcpy(fp->name, AudioEpcm16, sizeof fp->name); fp->format_id = AUDIO_ENCODING_PCM16; break; default: @@ -1542,54 +1543,61 @@ aria_mixer_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_INPUT_CLASS; dip->next = ARIAMIX_MIC_MUTE; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ARIAMIX_LINE_IN_LVL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_INPUT_CLASS; dip->next = ARIAMIX_LINE_IN_MUTE; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ARIAMIX_CD_LVL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_INPUT_CLASS; dip->next = ARIAMIX_CD_MUTE; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ARIAMIX_TEL_LVL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_INPUT_CLASS; dip->next = ARIAMIX_TEL_MUTE; - strcpy(dip->label.name, "telephone"); + strlcpy(dip->label.name, "telephone", sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ARIAMIX_DAC_LVL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_INPUT_CLASS; dip->next = ARIAMIX_DAC_MUTE; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ARIAMIX_AUX_LVL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_INPUT_CLASS; dip->next = ARIAMIX_AUX_MUTE; - strcpy(dip->label.name, AudioNoutput); + strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ARIAMIX_MIC_MUTE: @@ -1619,11 +1627,13 @@ aria_mixer_query_devinfo(addr, dip) mode: dip->mixer_class = ARIAMIX_INPUT_CLASS; dip->type = AUDIO_MIXER_ENUM; - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[1].ord = 1; break; @@ -1631,9 +1641,10 @@ mode: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_OUTPUT_CLASS; dip->next = ARIAMIX_MASTER_TREBLE; - strcpy(dip->label.name, AudioNvolume); + strlcpy(dip->label.name, AudioNvolume, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ARIAMIX_MASTER_TREBLE: @@ -1641,69 +1652,80 @@ mode: dip->mixer_class = ARIAMIX_OUTPUT_CLASS; dip->prev = ARIAMIX_MASTER_LVL; dip->next = ARIAMIX_MASTER_BASS; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNtreble); + strlcpy(dip->un.v.units.name, AudioNtreble, + sizeof dip->un.v.units.name); break; case ARIAMIX_MASTER_BASS: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_OUTPUT_CLASS; dip->prev = ARIAMIX_MASTER_TREBLE; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNbass); + strlcpy(dip->un.v.units.name, AudioNbass, + sizeof dip->un.v.units.name); break; case ARIAMIX_OUT_LVL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = ARIAMIX_OUTPUT_CLASS; - strcpy(dip->label.name, AudioNoutput); + strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ARIAMIX_RECORD_SOURCE: dip->mixer_class = ARIAMIX_RECORD_CLASS; dip->type = AUDIO_MIXER_ENUM; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->un.e.num_mem = 6; - strcpy(dip->un.e.member[0].label.name, AudioNoutput); + strlcpy(dip->un.e.member[0].label.name, AudioNoutput, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = ARIAMIX_AUX_LVL; - strcpy(dip->un.e.member[1].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[1].label.name, AudioNmicrophone, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[1].ord = ARIAMIX_MIC_LVL; - strcpy(dip->un.e.member[2].label.name, AudioNdac); + strlcpy(dip->un.e.member[2].label.name, AudioNdac, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[2].ord = ARIAMIX_DAC_LVL; - strcpy(dip->un.e.member[3].label.name, AudioNline); + strlcpy(dip->un.e.member[3].label.name, AudioNline, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[3].ord = ARIAMIX_LINE_IN_LVL; - strcpy(dip->un.e.member[3].label.name, AudioNcd); + strlcpy(dip->un.e.member[3].label.name, AudioNcd, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[4].ord = ARIAMIX_CD_LVL; - strcpy(dip->un.e.member[3].label.name, "telephone"); + strlcpy(dip->un.e.member[3].label.name, "telephone", + sizeof dip->un.e.member[0].label.name); dip->un.e.member[5].ord = ARIAMIX_TEL_LVL; break; case ARIAMIX_INPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = ARIAMIX_INPUT_CLASS; - strcpy(dip->label.name, AudioCInputs); + strlcpy(dip->label.name, AudioCInputs, sizeof dip->label.name); break; case ARIAMIX_OUTPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = ARIAMIX_OUTPUT_CLASS; - strcpy(dip->label.name, AudioCOutputs); + strlcpy(dip->label.name, AudioCOutputs, + sizeof dip->label.name); break; case ARIAMIX_RECORD_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = ARIAMIX_RECORD_CLASS; - strcpy(dip->label.name, AudioCRecord); + strlcpy(dip->label.name, AudioCRecord, sizeof dip->label.name); break; case ARIAMIX_EQ_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = ARIAMIX_EQ_CLASS; - strcpy(dip->label.name, AudioCEqualization); + strlcpy(dip->label.name, AudioCEqualization, + sizeof dip->label.name); break; default: diff --git a/sys/dev/isa/ess.c b/sys/dev/isa/ess.c index 69b4a903f3f..64ce29bce11 100644 --- a/sys/dev/isa/ess.c +++ b/sys/dev/isa/ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ess.c,v 1.8 2002/03/14 03:16:05 millert Exp $ */ +/* $OpenBSD: ess.c,v 1.9 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: ess.c,v 1.44.4.1 1999/06/21 01:18:00 thorpej Exp $ */ /* @@ -1005,8 +1005,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.name, "0x%04x", + sc->sc_version); if (ESS_USE_AUDIO1(sc->sc_model)) audio_attach_mi(&ess_1788_hw_if, sc, &sc->sc_dev); @@ -1133,49 +1135,49 @@ ess_query_encoding(addr, fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; return (0); case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; return (0); case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return (0); case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; return (0); case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -1916,10 +1918,11 @@ ess_query_devinfo(addr, dip) case ESS_DAC_PLAY_VOL: dip->mixer_class = ESS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_MIC_PLAY_VOL: @@ -1929,93 +1932,103 @@ ess_query_devinfo(addr, dip) dip->next = AUDIO_MIXER_LAST; else dip->next = ESS_MIC_PREAMP; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_LINE_PLAY_VOL: dip->mixer_class = ESS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_SYNTH_PLAY_VOL: dip->mixer_class = ESS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNfmsynth); + strlcpy(dip->label.name, AudioNfmsynth, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_CD_PLAY_VOL: dip->mixer_class = ESS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_AUXB_PLAY_VOL: dip->mixer_class = ESS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "auxb"); + strlcpy(dip->label.name, "auxb", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_INPUT_CLASS: dip->mixer_class = ESS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; return (0); case ESS_MASTER_VOL: dip->mixer_class = ESS_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_PCSPEAKER_VOL: dip->mixer_class = ESS_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "pc_speaker"); + strlcpy(dip->label.name, "pc_speaker", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_OUTPUT_CLASS: dip->mixer_class = ESS_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; return (0); case ESS_RECORD_VOL: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNrecord); + strlcpy(dip->label.name, AudioNrecord, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_RECORD_SOURCE: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); if (ESS_USE_AUDIO1(sc->sc_model)) { /* * The 1788 doesn't use the input mixer control that @@ -2028,28 +2041,40 @@ ess_query_devinfo(addr, dip) */ dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 4; - strcpy(dip->un.e.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[0].label.name, + AudioNmicrophone, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = ESS_SOURCE_MIC; - strcpy(dip->un.e.member[1].label.name, AudioNline); + strlcpy(dip->un.e.member[1].label.name, AudioNline, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = ESS_SOURCE_LINE; - strcpy(dip->un.e.member[2].label.name, AudioNcd); + strlcpy(dip->un.e.member[2].label.name, AudioNcd, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = ESS_SOURCE_CD; - strcpy(dip->un.e.member[3].label.name, AudioNmixerout); + strlcpy(dip->un.e.member[3].label.name, AudioNmixerout, + sizeof dip->un.e.member[3].label.name); dip->un.e.member[3].ord = ESS_SOURCE_MIXER; } else { dip->type = AUDIO_MIXER_SET; dip->un.s.num_mem = 6; - strcpy(dip->un.s.member[0].label.name, AudioNdac); + strlcpy(dip->un.s.member[0].label.name, AudioNdac, + sizeof dip->un.e.member[0].label.name); dip->un.s.member[0].mask = 1 << ESS_DAC_REC_VOL; - strcpy(dip->un.s.member[1].label.name, AudioNmicrophone); + strlcpy(dip->un.s.member[1].label.name, + AudioNmicrophone, + sizeof dip->un.e.member[1].label.name); dip->un.s.member[1].mask = 1 << ESS_MIC_REC_VOL; - strcpy(dip->un.s.member[2].label.name, AudioNline); + strlcpy(dip->un.s.member[2].label.name, AudioNline, + sizeof dip->un.e.member[2].label.name); dip->un.s.member[2].mask = 1 << ESS_LINE_REC_VOL; - strcpy(dip->un.s.member[3].label.name, AudioNfmsynth); + strlcpy(dip->un.s.member[3].label.name, AudioNfmsynth, + sizeof dip->un.e.member[3].label.name); dip->un.s.member[3].mask = 1 << ESS_SYNTH_REC_VOL; - strcpy(dip->un.s.member[4].label.name, AudioNcd); + strlcpy(dip->un.s.member[4].label.name, AudioNcd, + sizeof dip->un.e.member[4].label.name); dip->un.s.member[4].mask = 1 << ESS_CD_REC_VOL; - strcpy(dip->un.s.member[5].label.name, "auxb"); + strlcpy(dip->un.s.member[5].label.name, "auxb", + sizeof dip->un.e.member[5].label.name); dip->un.s.member[5].mask = 1 << ESS_AUXB_REC_VOL; } return (0); @@ -2057,26 +2082,29 @@ ess_query_devinfo(addr, dip) case ESS_RECORD_CLASS: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; return (0); case ESS_RECORD_MONITOR: dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->type = AUDIO_MIXER_ENUM; dip->mixer_class = ESS_MONITOR_CLASS; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; return (0); case ESS_MONITOR_CLASS: dip->mixer_class = ESS_MONITOR_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCmonitor); + strlcpy(dip->label.name, AudioCmonitor, + sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; return (0); } @@ -2088,67 +2116,77 @@ ess_query_devinfo(addr, dip) case ESS_DAC_REC_VOL: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_MIC_REC_VOL: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_LINE_REC_VOL: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_SYNTH_REC_VOL: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNfmsynth); + strlcpy(dip->label.name, AudioNfmsynth, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_CD_REC_VOL: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_AUXB_REC_VOL: dip->mixer_class = ESS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "auxb"); + strlcpy(dip->label.name, "auxb", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case ESS_MIC_PREAMP: dip->mixer_class = ESS_INPUT_CLASS; dip->prev = ESS_MIC_PLAY_VOL; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNpreamp); + strlcpy(dip->label.name, AudioNpreamp, sizeof dip->label.name); dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; return (0); } diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index b440b140d41..a42d77f696a 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gus.c,v 1.24 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: gus.c,v 1.25 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -2903,9 +2903,10 @@ gusmax_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSMAX_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSMAX_MIC_IN_MUTE; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; #endif @@ -2914,9 +2915,10 @@ gusmax_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSMAX_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSMAX_MONO_MUTE; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSMAX_DAC_LVL: /* dacout */ @@ -2924,9 +2926,10 @@ gusmax_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSMAX_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSMAX_DAC_MUTE; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSMAX_LINE_IN_LVL: /* line */ @@ -2934,9 +2937,10 @@ gusmax_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSMAX_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSMAX_LINE_IN_MUTE; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSMAX_CD_LVL: /* cd */ @@ -2944,9 +2948,10 @@ gusmax_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSMAX_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSMAX_CD_MUTE; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; @@ -2955,18 +2960,20 @@ gusmax_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSMAX_MONITOR_CLASS; dip->next = GUSMAX_MONITOR_MUTE; dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmonitor); + strlcpy(dip->label.name, AudioNmonitor, sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSMAX_OUT_LVL: /* cs4231 output volume: not useful? */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = GUSMAX_MONITOR_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNoutput); + strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSMAX_SPEAKER_LVL: /* fake speaker volume */ @@ -2974,9 +2981,10 @@ gusmax_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSMAX_MONITOR_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSMAX_SPEAKER_MUTE; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSMAX_LINE_IN_MUTE: @@ -3020,11 +3028,13 @@ gusmax_mixer_query_devinfo(addr, dip) dip->prev = GUSMAX_SPEAKER_LVL; dip->next = AUDIO_MIXER_LAST; mute: - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; @@ -3033,9 +3043,9 @@ gusmax_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSMAX_RECORD_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSMAX_RECORD_SOURCE; - strcpy(dip->label.name, AudioNrecord); + strlcpy(dip->label.name, AudioNrecord, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); break; case GUSMAX_RECORD_SOURCE: @@ -3043,15 +3053,19 @@ gusmax_mixer_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_ENUM; dip->prev = GUSMAX_REC_LVL; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->un.e.num_mem = 4; - strcpy(dip->un.e.member[0].label.name, AudioNoutput); + strlcpy(dip->un.e.member[0].label.name, AudioNoutput, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = DAC_IN_PORT; - strcpy(dip->un.e.member[1].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[1].label.name, AudioNmicrophone, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = MIC_IN_PORT; - strcpy(dip->un.e.member[2].label.name, AudioNdac); + strlcpy(dip->un.e.member[2].label.name, AudioNdac, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = AUX1_IN_PORT; - strcpy(dip->un.e.member[3].label.name, AudioNline); + strlcpy(dip->un.e.member[3].label.name, AudioNline, + sizeof dip->un.e.member[3].label.name); dip->un.e.member[3].ord = LINE_IN_PORT; break; @@ -3059,28 +3073,28 @@ gusmax_mixer_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = GUSMAX_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); break; case GUSMAX_OUTPUT_CLASS: /* output class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = GUSMAX_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, sizeof dip->label.name); break; case GUSMAX_MONITOR_CLASS: /* monitor class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = GUSMAX_MONITOR_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCmonitor); + strlcpy(dip->label.name, AudioCmonitor, sizeof dip->label.name); break; case GUSMAX_RECORD_CLASS: /* record source class */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = GUSMAX_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); break; default: @@ -3110,9 +3124,11 @@ gus_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSICS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSICS_MIC_IN_MUTE; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSICS_LINE_IN_LVL: /* line */ @@ -3120,9 +3136,10 @@ gus_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSICS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSICS_LINE_IN_MUTE; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSICS_CD_LVL: /* cd */ @@ -3130,9 +3147,10 @@ gus_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSICS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSICS_CD_MUTE; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSICS_DAC_LVL: /* dacout */ @@ -3140,9 +3158,10 @@ gus_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSICS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSICS_DAC_MUTE; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case GUSICS_MASTER_LVL: /* master output */ @@ -3150,9 +3169,10 @@ gus_mixer_query_devinfo(addr, dip) dip->mixer_class = GUSICS_OUTPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = GUSICS_MASTER_MUTE; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; @@ -3190,11 +3210,13 @@ gus_mixer_query_devinfo(addr, dip) dip->prev = GUSICS_MASTER_LVL; dip->next = AUDIO_MIXER_LAST; mute: - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; @@ -3202,9 +3224,10 @@ mute: dip->mixer_class = GUSICS_RECORD_CLASS; dip->type = AUDIO_MIXER_ENUM; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->un.e.num_mem = 1; - strcpy(dip->un.e.member[0].label.name, AudioNoutput); + strlcpy(dip->un.e.member[0].label.name, AudioNoutput, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = GUSICS_MASTER_LVL; break; @@ -3212,21 +3235,21 @@ mute: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = GUSICS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); break; case GUSICS_OUTPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = GUSICS_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, sizeof dip->label.name); break; case GUSICS_RECORD_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = GUSICS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); break; default: @@ -3244,49 +3267,49 @@ gus_query_encoding(addr, fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 1: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; case 2: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 3: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; case 4: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 5: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 6: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 7: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -3528,7 +3551,8 @@ gus_subattach(sc, ia) } sc->sc_dsize = i; - sprintf(gus_device.version, "3.%d", sc->sc_revision); + snprintf(gus_device.version, sizeof gus_device.version, "3.%d", + sc->sc_revision); printf(": ver 3.%d, %dKB DRAM, ", sc->sc_revision, sc->sc_dsize); diff --git a/sys/dev/isa/if_lc_isa.c b/sys/dev/isa/if_lc_isa.c index b87a2155b41..db5fa49456f 100644 --- a/sys/dev/isa/if_lc_isa.c +++ b/sys/dev/isa/if_lc_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lc_isa.c,v 1.2 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: if_lc_isa.c,v 1.3 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: if_lc_isa.c,v 1.10 2001/06/13 10:46:03 wiz Exp $ */ /*- @@ -197,7 +197,8 @@ lemac_isa_probe(parent, match, aux) struct cfdata *cf = match; struct lemac_softc sc; - 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/isapnp.c b/sys/dev/isa/isapnp.c index 9363a402c38..3768317b4f7 100644 --- a/sys/dev/isa/isapnp.c +++ b/sys/dev/isa/isapnp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isapnp.c,v 1.34 2002/07/07 18:20:00 miod Exp $ */ +/* $OpenBSD: isapnp.c,v 1.35 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: isapnp.c,v 1.9.4.3 1997/10/29 00:40:43 thorpej Exp $ */ /* @@ -862,7 +862,8 @@ isapnp_match(parent, match, aux) sc.sc_iot = ia->ia_iot; sc.sc_ncards = 0; - (void) strcpy(sc.sc_dev.dv_xname, "(isapnp probe)"); + (void) strlcpy(sc.sc_dev.dv_xname, "(isapnp probe)", + sizeof sc.sc_dev.dv_xname); if (isapnp_map(&sc)) return 0; diff --git a/sys/dev/isa/midi_pcppi.c b/sys/dev/isa/midi_pcppi.c index 394085a3d4f..ed303aef605 100644 --- a/sys/dev/isa/midi_pcppi.c +++ b/sys/dev/isa/midi_pcppi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi_pcppi.c,v 1.2 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: midi_pcppi.c,v 1.3 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: midi_pcppi.c,v 1.4 1998/11/25 22:17:06 augustss Exp $ */ /* @@ -121,7 +121,7 @@ midi_pcppi_attach(parent, self, aux) ms = &sc->sc_midisyn; ms->mets = &midi_pcppi_hw; - strcpy(ms->name, "PC speaker"); + strlcpy(ms->name, "PC speaker", sizeof ms->name); ms->nvoice = 1; ms->flags = MS_DOALLOC | MS_FREQXLATE; ms->data = pa->pa_cookie; diff --git a/sys/dev/isa/opl_ess.c b/sys/dev/isa/opl_ess.c index f395b953852..aadb1665631 100644 --- a/sys/dev/isa/opl_ess.c +++ b/sys/dev/isa/opl_ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opl_ess.c,v 1.2 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: opl_ess.c,v 1.3 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: opl_ess.c,v 1.3 1998/12/08 14:26:57 augustss Exp $ */ /* @@ -99,7 +99,7 @@ opl_ess_attach(parent, self, aux) sc->offs = 0; sc->spkrctl = ess_speaker_ctl; sc->spkrarg = ssc; - strcpy(sc->syn.name, "ESS "); + strlcpy(sc->syn.name, "ESS ", sizeof sc->syn.name); opl_attach(sc); } diff --git a/sys/dev/isa/opl_sb.c b/sys/dev/isa/opl_sb.c index 0e69cceff8c..d817c6b71be 100644 --- a/sys/dev/isa/opl_sb.c +++ b/sys/dev/isa/opl_sb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opl_sb.c,v 1.2 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: opl_sb.c,v 1.3 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: opl_sb.c,v 1.4 1998/12/08 14:26:57 augustss Exp $ */ /* @@ -107,7 +107,7 @@ opl_sb_attach(parent, self, aux) sc->offs = 0; sc->spkrctl = sbdsp_speaker_ctl; sc->spkrarg = ssc; - strcpy(sc->syn.name, "SB "); + strlcpy(sc->syn.name, "SB ", sizeof sc->syn.name); opl_attach(sc); } diff --git a/sys/dev/isa/pas.c b/sys/dev/isa/pas.c index 76e8be0ecc2..c6879b40eab 100644 --- a/sys/dev/isa/pas.c +++ b/sys/dev/isa/pas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pas.c,v 1.23 2002/06/14 21:34:59 todd Exp $ */ +/* $OpenBSD: pas.c,v 1.24 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: pas.c,v 1.37 1998/01/12 09:43:43 thorpej Exp $ */ /* @@ -417,8 +417,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/pss.c b/sys/dev/isa/pss.c index 8c21abfe361..bc90bb8c802 100644 --- a/sys/dev/isa/pss.c +++ b/sys/dev/isa/pss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pss.c,v 1.21 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: pss.c,v 1.22 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: pss.c,v 1.38 1998/01/12 09:43:44 thorpej Exp $ */ /* @@ -1425,9 +1425,10 @@ pss_query_devinfo(addr, dip) dip->mixer_class = PSS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = PSS_MIC_IN_MUTE; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case PSS_LINE_IN_LVL: /* line/CD */ @@ -1435,9 +1436,10 @@ pss_query_devinfo(addr, dip) dip->mixer_class = PSS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = PSS_LINE_IN_MUTE; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case PSS_DAC_LVL: /* dacout */ @@ -1445,9 +1447,10 @@ pss_query_devinfo(addr, dip) dip->mixer_class = PSS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = PSS_DAC_MUTE; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case PSS_REC_LVL: /* record level */ @@ -1455,18 +1458,20 @@ pss_query_devinfo(addr, dip) dip->mixer_class = PSS_RECORD_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = PSS_RECORD_SOURCE; - strcpy(dip->label.name, AudioNrecord); + strlcpy(dip->label.name, AudioNrecord, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case PSS_MON_LVL: /* monitor level */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = PSS_MONITOR_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmonitor); + strlcpy(dip->label.name, AudioNmonitor, sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case PSS_MASTER_VOL: /* master volume */ @@ -1474,55 +1479,57 @@ pss_query_devinfo(addr, dip) dip->mixer_class = PSS_OUTPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = PSS_OUTPUT_MODE; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case PSS_MASTER_TREBLE: /* master treble */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = PSS_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNtreble); + strlcpy(dip->label.name, AudioNtreble, sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNtreble); + strlcpy(dip->un.v.units.name, AudioNtreble, + sizeof dip->un.v.units.name); break; case PSS_MASTER_BASS: /* master bass */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = PSS_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNbass); + strlcpy(dip->label.name, AudioNbass, sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNbass); + strlcpy(dip->un.v.units.name, AudioNbass, sizeof dip->un.v.units.name); break; case PSS_OUTPUT_CLASS: /* output class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = PSS_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, sizeof dip->label.name); break; case PSS_INPUT_CLASS: /* input class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = PSS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); break; case PSS_MONITOR_CLASS: /* monitor class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = PSS_MONITOR_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCmonitor); + strlcpy(dip->label.name, AudioCmonitor, sizeof dip->label.name); break; case PSS_RECORD_CLASS: /* record source class */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = PSS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); break; case PSS_MIC_IN_MUTE: @@ -1545,11 +1552,13 @@ pss_query_devinfo(addr, dip) dip->prev = PSS_DAC_LVL; dip->next = AUDIO_MIXER_LAST; mute: - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; @@ -1558,15 +1567,19 @@ pss_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_ENUM; dip->prev = PSS_MASTER_VOL; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmode); + strlcpy(dip->label.name, AudioNmode, sizeof dip->label.name); dip->un.e.num_mem = 4; - strcpy(dip->un.e.member[0].label.name, AudioNmono); + strlcpy(dip->un.e.member[0].label.name, AudioNmono, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = PSS_SPKR_MONO; - strcpy(dip->un.e.member[1].label.name, AudioNstereo); + strlcpy(dip->un.e.member[1].label.name, AudioNstereo, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = PSS_SPKR_STEREO; - strcpy(dip->un.e.member[2].label.name, AudioNpseudo); + strlcpy(dip->un.e.member[2].label.name, AudioNpseudo, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = PSS_SPKR_PSEUDO; - strcpy(dip->un.e.member[3].label.name, AudioNspatial); + strlcpy(dip->un.e.member[3].label.name, AudioNspatial, + sizeof dip->un.e.member[3].label.name); dip->un.e.member[3].ord = PSS_SPKR_SPATIAL; break; @@ -1575,13 +1588,16 @@ pss_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_ENUM; dip->prev = PSS_REC_LVL; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->un.e.num_mem = 3; - strcpy(dip->un.e.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[0].label.name, AudioNmicrophone, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = PSS_MIC_IN_LVL; - strcpy(dip->un.e.member[1].label.name, AudioNcd); + strlcpy(dip->un.e.member[1].label.name, AudioNcd, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = PSS_LINE_IN_LVL; - strcpy(dip->un.e.member[2].label.name, AudioNdac); + strlcpy(dip->un.e.member[2].label.name, AudioNdac, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = PSS_DAC_LVL; break; diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c index cf282d137ac..2b29d34e9c5 100644 --- a/sys/dev/isa/sb.c +++ b/sys/dev/isa/sb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sb.c,v 1.22 2002/03/14 03:16:05 millert Exp $ */ +/* $OpenBSD: sb.c,v 1.23 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: sb.c,v 1.57 1998/01/12 09:43:46 thorpej Exp $ */ /* @@ -298,17 +298,17 @@ sb_getdev(addr, retp) 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/sb_isa.c b/sys/dev/isa/sb_isa.c index a4ced78c864..999e9c6c7dd 100644 --- a/sys/dev/isa/sb_isa.c +++ b/sys/dev/isa/sb_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sb_isa.c,v 1.6 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: sb_isa.c,v 1.7 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: sb_isa.c,v 1.15 1997/11/30 15:32:25 drochner Exp $ */ /* @@ -97,7 +97,7 @@ sb_isa_match(parent, match, aux) #else sc->sc_dev.dv_cfdata = match; #endif - strcpy(sc->sc_dev.dv_xname, "sb"); + strlcpy(sc->sc_dev.dv_xname, "sb", sizeof sc->sc_dev.dv_xname); return sbfind(parent, sc, aux); } diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index 558ecd96efa..82fb921b9bd 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdsp.c,v 1.21 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.22 2003/04/27 11:22:53 ho Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -458,25 +458,25 @@ sbdsp_query_encoding(addr, fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; return 0; case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return 0; case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return 0; case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = emul; @@ -487,25 +487,25 @@ sbdsp_query_encoding(addr, fp) switch(fp->index) { case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return 0; case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = emul; return 0; case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return 0; case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -1915,42 +1915,42 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = SB_OUTPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = chan; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_MIDI_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = class; dip->prev = AUDIO_MIXER_LAST; dip->next = is1745 ? SB_MIDI_IN_MUTE : AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNfmsynth); + strlcpy(dip->label.name, AudioNfmsynth, sizeof dip->label.name); dip->un.v.num_channels = chan; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_CD_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = class; dip->prev = AUDIO_MIXER_LAST; dip->next = is1745 ? SB_CD_IN_MUTE : AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = chan; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_VOICE_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = class; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->un.v.num_channels = chan; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_OUTPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = SB_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, sizeof dip->label.name); return 0; } @@ -1963,9 +1963,10 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->mixer_class = class; dip->prev = AUDIO_MIXER_LAST; dip->next = is1745 ? SB_MIC_IN_MUTE : AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_LINE_IN_VOL: @@ -1973,72 +1974,86 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->mixer_class = class; dip->prev = AUDIO_MIXER_LAST; dip->next = is1745 ? SB_LINE_IN_MUTE : AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_RECORD_SOURCE: dip->mixer_class = SB_RECORD_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); if (ISSBM1745(sc)) { dip->type = AUDIO_MIXER_SET; dip->un.s.num_mem = 4; - strcpy(dip->un.s.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.s.member[0].label.name, + AudioNmicrophone, + sizeof dip->un.s.member[0].label.name); dip->un.s.member[0].mask = 1 << SB_MIC_VOL; - strcpy(dip->un.s.member[1].label.name, AudioNcd); + strlcpy(dip->un.s.member[1].label.name, + AudioNcd, sizeof dip->un.s.member[1].label.name); dip->un.s.member[1].mask = 1 << SB_CD_VOL; - strcpy(dip->un.s.member[2].label.name, AudioNline); + strlcpy(dip->un.s.member[2].label.name, + AudioNline, sizeof dip->un.s.member[2].label.name); dip->un.s.member[2].mask = 1 << SB_LINE_IN_VOL; - strcpy(dip->un.s.member[3].label.name, AudioNfmsynth); + strlcpy(dip->un.s.member[3].label.name, + AudioNfmsynth, + sizeof dip->un.s.member[3].label.name); dip->un.s.member[3].mask = 1 << SB_MIDI_VOL; } else { dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 3; - strcpy(dip->un.e.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[0].label.name, + AudioNmicrophone, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = SB_MIC_VOL; - strcpy(dip->un.e.member[1].label.name, AudioNcd); + strlcpy(dip->un.e.member[1].label.name, AudioNcd, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = SB_CD_VOL; - strcpy(dip->un.e.member[2].label.name, AudioNline); + strlcpy(dip->un.e.member[2].label.name, AudioNline, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = SB_LINE_IN_VOL; } return 0; case SB_BASS: dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNbass); + strlcpy(dip->label.name, AudioNbass, sizeof dip->label.name); if (sc->sc_mixer_model == SBM_CT1745) { dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = SB_EQUALIZATION_CLASS; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNbass); + strlcpy(dip->un.v.units.name, AudioNbass, sizeof dip->un.v.units.name); } else { dip->type = AUDIO_MIXER_ENUM; dip->mixer_class = SB_INPUT_CLASS; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; } return 0; case SB_TREBLE: dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNtreble); + strlcpy(dip->label.name, AudioNtreble, sizeof dip->label.name); if (sc->sc_mixer_model == SBM_CT1745) { dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = SB_EQUALIZATION_CLASS; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNtreble); + strlcpy(dip->un.v.units.name, AudioNtreble, sizeof dip->un.v.units.name); } else { dip->type = AUDIO_MIXER_ENUM; dip->mixer_class = SB_INPUT_CLASS; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; } return 0; @@ -2047,14 +2062,14 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = SB_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); return 0; case SB_INPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = SB_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); return 0; } @@ -2067,38 +2082,40 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = SB_INPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "pc_speaker"); + strlcpy(dip->label.name, "pc_speaker", sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_INPUT_GAIN: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = SB_INPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNinput); + strlcpy(dip->label.name, AudioNinput, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_OUTPUT_GAIN: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = SB_OUTPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNoutput); + strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return 0; case SB_AGC: dip->type = AUDIO_MIXER_ENUM; dip->mixer_class = SB_INPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "agc"); + strlcpy(dip->label.name, "agc", sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; return 0; @@ -2106,7 +2123,7 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = SB_EQUALIZATION_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCequalization); + strlcpy(dip->label.name, AudioCequalization, sizeof dip->label.name); return 0; case SB_CD_IN_MUTE: @@ -2153,7 +2170,7 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->next = AUDIO_MIXER_LAST; swap: dip->mixer_class = SB_INPUT_CLASS; - strcpy(dip->label.name, AudioNswap); + strlcpy(dip->label.name, AudioNswap, sizeof dip->label.name); goto mute1; case SB_CD_OUT_MUTE: @@ -2173,13 +2190,15 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->next = AUDIO_MIXER_LAST; dip->mixer_class = SB_OUTPUT_CLASS; mute: - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); mute1: dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; return 0; diff --git a/sys/dev/isa/wss.c b/sys/dev/isa/wss.c index bc9003dace5..879a09b06b1 100644 --- a/sys/dev/isa/wss.c +++ b/sys/dev/isa/wss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wss.c,v 1.21 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: wss.c,v 1.22 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: wss.c,v 1.42 1998/01/19 22:18:23 augustss Exp $ */ /* @@ -211,9 +211,9 @@ wss_query_devinfo(addr, dip) dip->mixer_class = WSS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = WSS_MIC_IN_MUTE; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); break; case WSS_LINE_IN_LVL: /* line/CD */ @@ -221,9 +221,9 @@ wss_query_devinfo(addr, dip) dip->mixer_class = WSS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = WSS_LINE_IN_MUTE; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); break; case WSS_DAC_LVL: /* dacout */ @@ -231,9 +231,9 @@ wss_query_devinfo(addr, dip) dip->mixer_class = WSS_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = WSS_DAC_MUTE; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); break; case WSS_REC_LVL: /* record level */ @@ -241,39 +241,39 @@ wss_query_devinfo(addr, dip) dip->mixer_class = WSS_RECORD_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = WSS_RECORD_SOURCE; - strcpy(dip->label.name, AudioNrecord); + strlcpy(dip->label.name, AudioNrecord, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); break; case WSS_MON_LVL: /* monitor level */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = WSS_MONITOR_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmonitor); + strlcpy(dip->label.name, AudioNmonitor, sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); break; case WSS_INPUT_CLASS: /* input class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = WSS_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); break; case WSS_MONITOR_CLASS: /* monitor class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = WSS_MONITOR_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCmonitor); + strlcpy(dip->label.name, AudioCmonitor, sizeof dip->label.name); break; case WSS_RECORD_CLASS: /* record source class */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = WSS_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); break; case WSS_MIC_IN_MUTE: @@ -296,11 +296,13 @@ wss_query_devinfo(addr, dip) dip->prev = WSS_DAC_LVL; dip->next = AUDIO_MIXER_LAST; mute: - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; @@ -309,13 +311,16 @@ wss_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_ENUM; dip->prev = WSS_REC_LVL; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->un.e.num_mem = 3; - strcpy(dip->un.e.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[0].label.name, AudioNmicrophone, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = WSS_MIC_IN_LVL; - strcpy(dip->un.e.member[1].label.name, AudioNcd); + strlcpy(dip->un.e.member[1].label.name, AudioNcd, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = WSS_LINE_IN_LVL; - strcpy(dip->un.e.member[2].label.name, AudioNdac); + strlcpy(dip->un.e.member[2].label.name, AudioNdac, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = WSS_DAC_LVL; break; diff --git a/sys/dev/isa/ym.c b/sys/dev/isa/ym.c index 5a25fc7136b..d96cc31f40c 100644 --- a/sys/dev/isa/ym.c +++ b/sys/dev/isa/ym.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ym.c,v 1.11 2002/03/14 03:16:05 millert Exp $ */ +/* $OpenBSD: ym.c,v 1.12 2003/04/27 11:22:53 ho Exp $ */ /* @@ -453,8 +453,9 @@ ym_query_devinfo(addr, dip) case YM_EQ_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = dip->index; - strcpy(dip->label.name, - mixer_classes[dip->index - YM_INPUT_CLASS]); + strlcpy(dip->label.name, + mixer_classes[dip->index - YM_INPUT_CLASS], + sizeof dip->label.name); break; case YM_MIDI_LVL: @@ -472,7 +473,9 @@ ym_query_devinfo(addr, dip) dip->next = dip->index + 7; - strcpy(dip->label.name, mixer_port_names[dip->index - YM_MIDI_LVL]); + strlcpy(dip->label.name, + mixer_port_names[dip->index - YM_MIDI_LVL], + sizeof dip->label.name); if (dip->index == YM_SPEAKER_LVL || dip->index == YM_MIC_LVL) @@ -480,7 +483,8 @@ ym_query_devinfo(addr, dip) else dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case YM_MIDI_MUTE: @@ -497,11 +501,13 @@ ym_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_ENUM; dip->prev = dip->index - 7; mute: - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; @@ -510,9 +516,10 @@ mute: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = YM_OUTPUT_CLASS; dip->next = YM_OUTPUT_MUTE; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case YM_OUTPUT_MUTE: @@ -525,9 +532,10 @@ mute: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = YM_RECORD_CLASS; dip->next = YM_RECORD_SOURCE; - strcpy(dip->label.name, AudioNrecord); + strlcpy(dip->label.name, AudioNrecord, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; @@ -535,56 +543,69 @@ mute: dip->mixer_class = YM_RECORD_CLASS; dip->type = AUDIO_MIXER_ENUM; dip->prev = YM_REC_LVL; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->un.e.num_mem = 4; - strcpy(dip->un.e.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[0].label.name, AudioNmicrophone, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = MIC_IN_PORT; - strcpy(dip->un.e.member[1].label.name, AudioNline); + strlcpy(dip->un.e.member[1].label.name, AudioNline, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = LINE_IN_PORT; - strcpy(dip->un.e.member[2].label.name, AudioNdac); + strlcpy(dip->un.e.member[2].label.name, AudioNdac, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = DAC_IN_PORT; - strcpy(dip->un.e.member[3].label.name, AudioNcd); + strlcpy(dip->un.e.member[3].label.name, AudioNcd, + sizeof dip->un.e.member[3].label.name); dip->un.e.member[3].ord = AUX1_IN_PORT; break; case YM_MASTER_EQMODE: dip->type = AUDIO_MIXER_ENUM; dip->mixer_class = YM_EQ_CLASS; - strcpy(dip->label.name, AudioNmode); - strcpy(dip->un.v.units.name, AudioNmode); + strlcpy(dip->label.name, AudioNmode, sizeof dip->label.name); + strlcpy(dip->un.v.units.name, AudioNmode, + sizeof dip->un.v.units.name); dip->un.e.num_mem = 4; - strcpy(dip->un.e.member[0].label.name, AudioNdesktop); + strlcpy(dip->un.e.member[0].label.name, AudioNdesktop, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = SA3_SYS_CTL_YMODE0; - strcpy(dip->un.e.member[1].label.name, AudioNlaptop); + strlcpy(dip->un.e.member[1].label.name, AudioNlaptop, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = SA3_SYS_CTL_YMODE1; - strcpy(dip->un.e.member[2].label.name, AudioNsubnote); + strlcpy(dip->un.e.member[2].label.name, AudioNsubnote, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = SA3_SYS_CTL_YMODE2; - strcpy(dip->un.e.member[3].label.name, AudioNhifi); + strlcpy(dip->un.e.member[3].label.name, AudioNhifi, + sizeof dip->un.e.member[3].label.name); dip->un.e.member[3].ord = SA3_SYS_CTL_YMODE3; break; case YM_MASTER_TREBLE: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = YM_EQ_CLASS; - strcpy(dip->label.name, AudioNtreble); + strlcpy(dip->label.name, AudioNtreble, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNtreble); + strlcpy(dip->un.v.units.name, AudioNtreble, + sizeof dip->un.v.units.name); break; case YM_MASTER_BASS: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = YM_EQ_CLASS; - strcpy(dip->label.name, AudioNbass); + strlcpy(dip->label.name, AudioNbass, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNbass); + strlcpy(dip->un.v.units.name, AudioNbass, + sizeof dip->un.v.units.name); break; case YM_MASTER_WIDE: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = YM_EQ_CLASS; - strcpy(dip->label.name, AudioNsurround); + strlcpy(dip->label.name, AudioNsurround, + sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNsurround); + strlcpy(dip->un.v.units.name, AudioNsurround, + sizeof dip->un.v.units.name); break; default: diff --git a/sys/dev/microcode/aic7xxx/aicasm_gram.y b/sys/dev/microcode/aic7xxx/aicasm_gram.y index d9f2ba4cbcc..6b88e2c0372 100644 --- a/sys/dev/microcode/aic7xxx/aicasm_gram.y +++ b/sys/dev/microcode/aic7xxx/aicasm_gram.y @@ -1827,10 +1827,7 @@ add_version(const char *verstring) versions = realloc(versions, newlen + oldlen + 2); if (versions == NULL) stop("Can't allocate version string", EX_SOFTWARE); - strcpy(&versions[oldlen], prefix); - strcpy(&versions[oldlen + strlen(prefix)], verstring); - versions[newlen + oldlen] = '\n'; - versions[newlen + oldlen + 1] = '\0'; + snprintf(&versions[oldlen], newlen + 2, "%s%s\n", prefix, verstring); } void diff --git a/sys/dev/ofw/ofcons.c b/sys/dev/ofw/ofcons.c index c831bd4baa2..ee04c8dd04f 100644 --- a/sys/dev/ofw/ofcons.c +++ b/sys/dev/ofw/ofcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofcons.c,v 1.9 2002/03/14 01:26:58 millert Exp $ */ +/* $OpenBSD: ofcons.c,v 1.10 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: ofcons.c,v 1.3 1996/10/13 01:38:11 christos Exp $ */ /* @@ -393,7 +393,7 @@ ofprintf(char *fmt, ...) va_start(ap, fmt); - vsprintf(buf, fmt, ap); + vsnprintf(buf, sizeof buf, fmt, ap); c = buf; while (*c != '\0') { diff --git a/sys/dev/pci/ami_pci.c b/sys/dev/pci/ami_pci.c index 3f560e8ecb1..709176e1889 100644 --- a/sys/dev/pci/ami_pci.c +++ b/sys/dev/pci/ami_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ami_pci.c,v 1.15 2003/02/28 15:26:23 mickey Exp $ */ +/* $OpenBSD: ami_pci.c,v 1.16 2003/04/27 11:22:53 ho Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -232,10 +232,11 @@ ami_pci_attach(parent, self, aux) for (vp = ami_pci_vendors; vp->id && vp->id != (csr & 0xffff); vp++); if (vp->id) - sprintf(modelbuf, "%s %x", vp->name, + snprintf(modelbuf, sizeof modelbuf, "%s %x", vp->name, (csr >> 16) & 0xffff); else - sprintf(modelbuf, "unknown 0x%08x", csr); + snprintf(modelbuf, sizeof modelbuf, "unknown 0x%08x", + csr); model = modelbuf; } diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c index efd64914024..25b781414be 100644 --- a/sys/dev/pci/auich.c +++ b/sys/dev/pci/auich.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auich.c,v 1.31 2003/03/19 20:15:02 mickey Exp $ */ +/* $OpenBSD: auich.c,v 1.32 2003/04/27 11:22:53 ho Exp $ */ /* * Copyright (c) 2000,2001 Michael Shalayeff @@ -356,8 +356,8 @@ auich_attach(parent, self, aux) return; } intrstr = pci_intr_string(pa->pa_pc, ih); - sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_AUDIO, auich_intr, sc, - sc->sc_dev.dv_xname); + sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_AUDIO, auich_intr, + sc, sc->sc_dev.dv_xname); if (!sc->sc_ih) { printf(": can't establish interrupt"); if (intrstr) @@ -372,9 +372,12 @@ auich_attach(parent, self, aux) if (PCI_PRODUCT(pa->pa_id) == auich_devices[i].product) break; - sprintf(sc->sc_audev.name, "%s AC97", auich_devices[i].name); - sprintf(sc->sc_audev.version, "0x%02x", PCI_REVISION(pa->pa_class)); - strcpy(sc->sc_audev.config, sc->sc_dev.dv_xname); + snprintf(sc->sc_audev.name, sizeof sc->sc_audev.name, "%s AC97", + auich_devices[i].name); + snprintf(sc->sc_audev.version, sizeof sc->sc_audev.version, "0x%02x", + PCI_REVISION(pa->pa_class)); + strlcpy(sc->sc_audev.config, sc->sc_dev.dv_xname, + sizeof sc->sc_audev.config); printf(": %s, %s\n", intrstr, sc->sc_audev.name); @@ -523,49 +526,49 @@ auich_query_encoding(v, aep) { switch (aep->index) { case 0: - strcpy(aep->name, AudioEulinear); + strlcpy(aep->name, AudioEulinear, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR; aep->precision = 8; aep->flags = 0; return (0); case 1: - strcpy(aep->name, AudioEmulaw); + strlcpy(aep->name, AudioEmulaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 2: - strcpy(aep->name, AudioEalaw); + strlcpy(aep->name, AudioEalaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ALAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 3: - strcpy(aep->name, AudioEslinear); + strlcpy(aep->name, AudioEslinear, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 4: - strcpy(aep->name, AudioEslinear_le); + strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; return (0); case 5: - strcpy(aep->name, AudioEulinear_le); + strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_LE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 6: - strcpy(aep->name, AudioEslinear_be); + strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 7: - strcpy(aep->name, AudioEulinear_be); + strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; diff --git a/sys/dev/pci/autri.c b/sys/dev/pci/autri.c index 023f9bc327a..c57514c16bf 100644 --- a/sys/dev/pci/autri.c +++ b/sys/dev/pci/autri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autri.c,v 1.12 2003/03/09 01:52:14 tedu Exp $ */ +/* $OpenBSD: autri.c,v 1.13 2003/04/27 11:22:53 ho Exp $ */ /* * Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro. @@ -935,49 +935,49 @@ autri_query_encoding(addr, fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; diff --git a/sys/dev/pci/auvia.c b/sys/dev/pci/auvia.c index 443c78a34d0..6e2036a1a0a 100644 --- a/sys/dev/pci/auvia.c +++ b/sys/dev/pci/auvia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auvia.c,v 1.23 2003/02/28 15:26:23 mickey Exp $ */ +/* $OpenBSD: auvia.c,v 1.24 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: auvia.c,v 1.7 2000/11/15 21:06:33 jdolecek Exp $ */ /*- @@ -463,49 +463,49 @@ auvia_query_encoding(void *addr, struct audio_encoding *fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; return (0); case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return (0); case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; diff --git a/sys/dev/pci/bktr/bktr_audio.c b/sys/dev/pci/bktr/bktr_audio.c index 02a8fc61439..db3d165bd17 100644 --- a/sys/dev/pci/bktr/bktr_audio.c +++ b/sys/dev/pci/bktr/bktr_audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_audio.c,v 1.3 2003/02/11 19:20:28 mickey Exp $ */ +/* $OpenBSD: bktr_audio.c,v 1.4 2003/04/27 11:22:54 ho Exp $ */ /* $FreeBSD: src/sys/dev/bktr/bktr_audio.c,v 1.8 2000/10/31 13:09:56 roger Exp $ */ /* * This is part of the Driver for Video Capture Cards (Frame grabbers) @@ -460,8 +460,9 @@ void msp_read_id( bktr_ptr_t bktr ){ rev1 = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x001e); rev2 = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x001f); - sprintf(bktr->msp_version_string, "34%02d%c-%c%d", - (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f); + snprintf(bktr->msp_version_string, sizeof bktr->msp_version_string, + "34%02d%c-%c%d", (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', + rev2&0x1f); } @@ -607,8 +608,9 @@ void dpl_read_id( bktr_ptr_t bktr ){ rev1 = msp_dpl_read(bktr, bktr->dpl_addr, 0x12, 0x001e); rev2 = msp_dpl_read(bktr, bktr->dpl_addr, 0x12, 0x001f); - sprintf(bktr->dpl_version_string, "34%02d%c-%c%d", - ((rev2>>8)&0xff)-1, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f); + snprintf(bktr->dpl_version_string, sizeof bktr->dpl_version_string, + "34%02d%c-%c%d", ((rev2>>8)&0xff)-1, (rev1&0xff)+'@', + ((rev1>>8)&0xff)+'@', rev2&0x1f); } /* Configure the DPL chip to Auto-detect the audio format */ diff --git a/sys/dev/pci/cmpci.c b/sys/dev/pci/cmpci.c index ce745f89864..c3605135f1c 100644 --- a/sys/dev/pci/cmpci.c +++ b/sys/dev/pci/cmpci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmpci.c,v 1.9 2002/11/19 18:40:17 jason Exp $ */ +/* $OpenBSD: cmpci.c,v 1.10 2003/04/27 11:22:53 ho Exp $ */ /* * Copyright (c) 2000 Takuya SHIOZAKI @@ -465,49 +465,49 @@ cmpci_query_encoding(handle, fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -792,152 +792,177 @@ cmpci_query_devinfo(handle, dip) dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_OUTPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_FM_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CMPCI_FM_IN_MUTE; - strcpy(dip->label.name, AudioNfmsynth); + strlcpy(dip->label.name, AudioNfmsynth, + sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_CD_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CMPCI_CD_IN_MUTE; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_VOICE_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_OUTPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_OUTPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = CMPCI_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, + sizeof dip->label.name); return 0; case CMPCI_MIC_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CMPCI_MIC_IN_MUTE; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_LINE_IN_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CMPCI_LINE_IN_MUTE; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_RECORD_SOURCE: dip->mixer_class = CMPCI_RECORD_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->type = AUDIO_MIXER_SET; #ifdef CMPCI_SPDIF_SUPPORT dip->un.s.num_mem = 5; #else dip->un.s.num_mem = 4; #endif - strcpy(dip->un.s.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.s.member[0].label.name, AudioNmicrophone, + sizeof dip->un.s.member[0].label.name); dip->un.s.member[0].mask = 1 << CMPCI_MIC_VOL; - strcpy(dip->un.s.member[1].label.name, AudioNcd); + strlcpy(dip->un.s.member[1].label.name, AudioNcd, + sizeof dip->un.s.member[1].label.name); dip->un.s.member[1].mask = 1 << CMPCI_CD_VOL; - strcpy(dip->un.s.member[2].label.name, AudioNline); + strlcpy(dip->un.s.member[2].label.name, AudioNline, + sizeof dip->un.s.member[2].label.name); dip->un.s.member[2].mask = 1 << CMPCI_LINE_IN_VOL; - strcpy(dip->un.s.member[3].label.name, AudioNfmsynth); + strlcpy(dip->un.s.member[3].label.name, AudioNfmsynth, + sizeof dip->un.s.member[3].label.name); dip->un.s.member[3].mask = 1 << CMPCI_FM_VOL; #ifdef CMPCI_SPDIF_SUPPORT - strcpy(dip->un.s.member[4].label.name, CmpciNspdif); + strlcpy(dip->un.s.member[4].label.name, CmpciNspdif, + sizeof dip->un.s.member[4].label.name); dip->un.s.member[4].mask = 1 << CMPCI_SPDIF_IN; #endif return 0; case CMPCI_BASS: dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNbass); + strlcpy(dip->label.name, AudioNbass, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_EQUALIZATION_CLASS; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNbass); + strlcpy(dip->un.v.units.name, AudioNbass, + sizeof dip->un.v.units.name); return 0; case CMPCI_TREBLE: dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNtreble); + strlcpy(dip->label.name, AudioNtreble, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_EQUALIZATION_CLASS; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNtreble); + strlcpy(dip->un.v.units.name, AudioNtreble, + sizeof dip->un.v.units.name); return 0; case CMPCI_RECORD_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = CMPCI_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, + sizeof dip->label.name); return 0; case CMPCI_INPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = CMPCI_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, + sizeof dip->label.name); return 0; case CMPCI_PCSPEAKER: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_INPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "pc_speaker"); + strlcpy(dip->label.name, "pc_speaker", sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_INPUT_GAIN: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_INPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNinput); + strlcpy(dip->label.name, AudioNinput, + sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_OUTPUT_GAIN: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CMPCI_OUTPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNoutput); + strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return 0; case CMPCI_AGC: dip->type = AUDIO_MIXER_ENUM; dip->mixer_class = CMPCI_INPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "agc"); + strlcpy(dip->label.name, "agc", sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; return 0; case CMPCI_EQUALIZATION_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = CMPCI_EQUALIZATION_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCequalization); + strlcpy(dip->label.name, AudioCequalization, + sizeof dip->label.name); return 0; case CMPCI_CD_IN_MUTE: dip->prev = CMPCI_CD_VOL; @@ -976,7 +1001,7 @@ cmpci_query_devinfo(handle, dip) dip->next = AUDIO_MIXER_LAST; swap: dip->mixer_class = CMPCI_INPUT_CLASS; - strcpy(dip->label.name, AudioNswap); + strlcpy(dip->label.name, AudioNswap, sizeof dip->label.name); goto mute1; case CMPCI_CD_OUT_MUTE: dip->prev = CMPCI_CD_SWAP; @@ -993,13 +1018,15 @@ cmpci_query_devinfo(handle, dip) dip->next = AUDIO_MIXER_LAST; dip->mixer_class = CMPCI_OUTPUT_CLASS; mute: - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); mute1: dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; return 0; } diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 904613ae5d0..0e3b1e5890a 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4280.c,v 1.16 2002/11/19 18:40:17 jason Exp $ */ +/* $OpenBSD: cs4280.c,v 1.17 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */ /* @@ -1025,49 +1025,49 @@ cs4280_query_encoding(addr, fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = 0; break; case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = 0; diff --git a/sys/dev/pci/cs4281.c b/sys/dev/pci/cs4281.c index ef4626f7188..036444a74d1 100644 --- a/sys/dev/pci/cs4281.c +++ b/sys/dev/pci/cs4281.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4281.c,v 1.12 2002/03/14 03:16:06 millert Exp $ */ +/* $OpenBSD: cs4281.c,v 1.13 2003/04/27 11:22:53 ho Exp $ */ /* $Tera: cs4281.c,v 1.18 2000/12/27 14:24:45 tacha Exp $ */ /* @@ -463,49 +463,49 @@ cs4281_query_encoding(addr, fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = 0; break; case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = 0; diff --git a/sys/dev/pci/eap.c b/sys/dev/pci/eap.c index f150af1a7ab..b3cb79e8b04 100644 --- a/sys/dev/pci/eap.c +++ b/sys/dev/pci/eap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eap.c,v 1.18 2003/04/05 19:15:52 millert Exp $ */ +/* $OpenBSD: eap.c,v 1.19 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: eap.c,v 1.46 2001/09/03 15:07:37 reinoud Exp $ */ /* @@ -834,49 +834,49 @@ eap_query_encoding(void *addr, struct audio_encoding *fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; return (0); case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return (0); case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -1408,100 +1408,121 @@ eap1370_query_devinfo(void *addr, mixer_devinfo_t *dip) dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = EAP_OUTPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case EAP_VOICE_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = EAP_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case EAP_FM_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = EAP_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNfmsynth); + strlcpy(dip->label.name, AudioNfmsynth, + sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case EAP_CD_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = EAP_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case EAP_LINE_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = EAP_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case EAP_AUX_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = EAP_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNaux); + strlcpy(dip->label.name, AudioNaux, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case EAP_MIC_VOL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = EAP_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = EAP_MIC_PREAMP; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); return (0); case EAP_RECORD_SOURCE: dip->mixer_class = EAP_RECORD_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->type = AUDIO_MIXER_SET; dip->un.s.num_mem = 6; - strcpy(dip->un.s.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.s.member[0].label.name, AudioNmicrophone, + sizeof dip->un.s.member[0].label.name); dip->un.s.member[0].mask = 1 << EAP_MIC_VOL; - strcpy(dip->un.s.member[1].label.name, AudioNcd); + strlcpy(dip->un.s.member[1].label.name, AudioNcd, + sizeof dip->un.s.member[1].label.name); dip->un.s.member[1].mask = 1 << EAP_CD_VOL; - strcpy(dip->un.s.member[2].label.name, AudioNline); + strlcpy(dip->un.s.member[2].label.name, AudioNline, + sizeof dip->un.s.member[2].label.name); dip->un.s.member[2].mask = 1 << EAP_LINE_VOL; - strcpy(dip->un.s.member[3].label.name, AudioNfmsynth); + strlcpy(dip->un.s.member[3].label.name, AudioNfmsynth, + sizeof dip->un.s.member[3].label.name); dip->un.s.member[3].mask = 1 << EAP_FM_VOL; - strcpy(dip->un.s.member[4].label.name, AudioNaux); + strlcpy(dip->un.s.member[4].label.name, AudioNaux, + sizeof dip->un.s.member[4].label.name); dip->un.s.member[4].mask = 1 << EAP_AUX_VOL; - strcpy(dip->un.s.member[5].label.name, AudioNdac); + strlcpy(dip->un.s.member[5].label.name, AudioNdac, + sizeof dip->un.s.member[5].label.name); dip->un.s.member[5].mask = 1 << EAP_VOICE_VOL; return (0); case EAP_OUTPUT_SELECT: dip->mixer_class = EAP_OUTPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNselect); + strlcpy(dip->label.name, AudioNselect, sizeof dip->label.name); dip->type = AUDIO_MIXER_SET; dip->un.s.num_mem = 6; - strcpy(dip->un.s.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.s.member[0].label.name, AudioNmicrophone, + sizeof dip->un.s.member[0].label.name); dip->un.s.member[0].mask = 1 << EAP_MIC_VOL; - strcpy(dip->un.s.member[1].label.name, AudioNcd); + strlcpy(dip->un.s.member[1].label.name, AudioNcd, + sizeof dip->un.s.member[1].label.name); dip->un.s.member[1].mask = 1 << EAP_CD_VOL; - strcpy(dip->un.s.member[2].label.name, AudioNline); + strlcpy(dip->un.s.member[2].label.name, AudioNline, + sizeof dip->un.s.member[2].label.name); dip->un.s.member[2].mask = 1 << EAP_LINE_VOL; - strcpy(dip->un.s.member[3].label.name, AudioNfmsynth); + strlcpy(dip->un.s.member[3].label.name, AudioNfmsynth, + sizeof dip->un.s.member[3].label.name); dip->un.s.member[3].mask = 1 << EAP_FM_VOL; - strcpy(dip->un.s.member[4].label.name, AudioNaux); + strlcpy(dip->un.s.member[4].label.name, AudioNaux, + sizeof dip->un.s.member[4].label.name); dip->un.s.member[4].mask = 1 << EAP_AUX_VOL; - strcpy(dip->un.s.member[5].label.name, AudioNdac); + strlcpy(dip->un.s.member[5].label.name, AudioNdac, + sizeof dip->un.s.member[5].label.name); dip->un.s.member[5].mask = 1 << EAP_VOICE_VOL; return (0); case EAP_MIC_PREAMP: @@ -1509,30 +1530,33 @@ eap1370_query_devinfo(void *addr, mixer_devinfo_t *dip) dip->mixer_class = EAP_INPUT_CLASS; dip->prev = EAP_MIC_VOL; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNpreamp); + strlcpy(dip->label.name, AudioNpreamp, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; return (0); case EAP_OUTPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = EAP_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, + sizeof dip->label.name); return (0); case EAP_RECORD_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = EAP_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); return (0); case EAP_INPUT_CLASS: dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = EAP_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); return (0); } return (ENXIO); diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c index 419e7eee451..9cc2f7fe1e9 100644 --- a/sys/dev/pci/emuxki.c +++ b/sys/dev/pci/emuxki.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emuxki.c,v 1.13 2003/04/26 08:01:42 jmc Exp $ */ +/* $OpenBSD: emuxki.c,v 1.14 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: emuxki.c,v 1.1 2001/10/17 18:39:41 jdolecek Exp $ */ /*- @@ -432,17 +432,18 @@ emuxki_attach(struct device *parent, struct device *self, void *aux) /* XXX it's unknown wheather APS is made from Audigy as well */ if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_AUDIGY) { sc->sc_type = EMUXKI_AUDIGY; - strcpy(sc->sc_audv.name, "Audigy"); + strlcpy(sc->sc_audv.name, "Audigy", sizeof sc->sc_audv.name); } else if (pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG) == EMU_SUBSYS_APS) { sc->sc_type = EMUXKI_APS; - strcpy(sc->sc_audv.name, "E-mu APS"); + strlcpy(sc->sc_audv.name, "E-mu APS", sizeof sc->sc_audv.name); } else { sc->sc_type = EMUXKI_SBLIVE; - strcpy(sc->sc_audv.name, "SB Live!"); + strlcpy(sc->sc_audv.name, "SB Live!", sizeof sc->sc_audv.name); } - sprintf(sc->sc_audv.version, "0x%02x", PCI_REVISION(pa->pa_class)); - strcpy(sc->sc_audv.config, "emuxki"); + snprintf(sc->sc_audv.version, sizeof sc->sc_audv.version, "0x%02x", + PCI_REVISION(pa->pa_class)); + strlcpy(sc->sc_audv.config, "emuxki", sizeof sc->sc_audv.config); if (emuxki_scinit(sc) || /* APS has no ac97 XXX */ @@ -1684,49 +1685,49 @@ emuxki_query_encoding(void *addr, struct audio_encoding *fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; diff --git a/sys/dev/pci/esa.c b/sys/dev/pci/esa.c index 16fd07940b1..54fbca9dc09 100644 --- a/sys/dev/pci/esa.c +++ b/sys/dev/pci/esa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esa.c,v 1.5 2002/11/19 18:40:17 jason Exp $ */ +/* $OpenBSD: esa.c,v 1.6 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: esa.c,v 1.12 2002/03/24 14:17:35 jmcneill Exp $ */ /* @@ -1020,7 +1020,7 @@ esa_attach(struct device *parent, struct device *self, void *aux) int revision, len; int i; - pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof devinfo); revision = PCI_REVISION(pa->pa_class); printf(": %s (rev. 0x%02x)\n", devinfo, revision); diff --git a/sys/dev/pci/eso.c b/sys/dev/pci/eso.c index 8fecf1c3dfd..0b23d15042b 100644 --- a/sys/dev/pci/eso.c +++ b/sys/dev/pci/eso.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eso.c,v 1.18 2002/06/09 02:31:20 mickey Exp $ */ +/* $OpenBSD: eso.c,v 1.19 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: eso.c,v 1.3 1999/08/02 17:37:43 augustss Exp $ */ /* @@ -656,13 +656,13 @@ eso_query_encoding(hdl, fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; case 1: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; @@ -670,14 +670,14 @@ eso_query_encoding(hdl, fp) case 2: fp->precision = 16; if (fp->flags & AUOPEN_READ) { - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; if (fp->flags & AUOPEN_WRITE) fp->flags = AUDIO_ENCODINGFLAG_EMULATED; else fp->flags = 0; } else { - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->flags = 0; } @@ -685,14 +685,14 @@ eso_query_encoding(hdl, fp) case 3: fp->precision = 16; if (fp->flags & AUOPEN_READ) { - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; if (fp->flags & AUOPEN_WRITE) fp->flags = AUDIO_ENCODINGFLAG_EMULATED; else fp->flags = 0; } else { - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->flags = 0; } @@ -700,10 +700,10 @@ eso_query_encoding(hdl, fp) case 4: fp->precision = 16; if (fp->flags & AUOPEN_READ) { - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; } else { - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; } fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -711,22 +711,22 @@ eso_query_encoding(hdl, fp) case 5: fp->precision = 16; if (fp->flags & AUOPEN_READ) { - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; } else { - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; } fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 6: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 7: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -916,20 +916,15 @@ eso_getdev(hdl, retp) { struct eso_softc *sc = hdl; - strncpy(retp->name, "ESS Solo-1", sizeof (retp->name)); -#ifdef __OpenBSD__ - /* This does not overflow. */ - sprintf(retp->version, "0x%02x", sc->sc_revision); -#else - snprintf(retp->version, sizeof (retp->version), "0x%02x", + strlcpy(retp->name, "ESS Solo-1", sizeof retp->name); + snprintf(retp->version, sizeof retp->version, "0x%02x", sc->sc_revision); -#endif if (sc->sc_revision <= sizeof (eso_rev2model) / sizeof (eso_rev2model[0])) - strncpy(retp->config, eso_rev2model[sc->sc_revision], - sizeof (retp->config)); + strlcpy(retp->config, eso_rev2model[sc->sc_revision], + sizeof retp->config); else - strncpy(retp->config, "unknown", sizeof (retp->config)); + strlcpy(retp->config, "unknown", sizeof retp->config); return (0); } @@ -1208,243 +1203,282 @@ eso_query_devinfo(hdl, dip) case ESO_DAC_PLAY_VOL: dip->mixer_class = ESO_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_MIC_PLAY_VOL: dip->mixer_class = ESO_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_LINE_PLAY_VOL: dip->mixer_class = ESO_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_SYNTH_PLAY_VOL: dip->mixer_class = ESO_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNfmsynth); + strlcpy(dip->label.name, AudioNfmsynth, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_MONO_PLAY_VOL: dip->mixer_class = ESO_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "mono_in"); + strlcpy(dip->label.name, "mono_in", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_CD_PLAY_VOL: dip->mixer_class = ESO_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_AUXB_PLAY_VOL: dip->mixer_class = ESO_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "auxb"); + strlcpy(dip->label.name, "auxb", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_MIC_PREAMP: dip->mixer_class = ESO_MICROPHONE_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNpreamp); + strlcpy(dip->label.name, AudioNpreamp, sizeof dip->label.name); dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; case ESO_MICROPHONE_CLASS: dip->mixer_class = ESO_MICROPHONE_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; break; case ESO_INPUT_CLASS: dip->mixer_class = ESO_INPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; break; case ESO_MASTER_VOL: dip->mixer_class = ESO_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmaster); + strlcpy(dip->label.name, AudioNmaster, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_PCSPEAKER_VOL: dip->mixer_class = ESO_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "pc_speaker"); + strlcpy(dip->label.name, "pc_speaker", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_MONOOUT_SOURCE: dip->mixer_class = ESO_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "mono_out"); + strlcpy(dip->label.name, "mono_out", sizeof dip->label.name); dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 3; - strcpy(dip->un.e.member[0].label.name, AudioNmute); + strlcpy(dip->un.e.member[0].label.name, AudioNmute, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = ESO_MIXREG_MPM_MOMUTE; - strcpy(dip->un.e.member[1].label.name, AudioNdac); + strlcpy(dip->un.e.member[1].label.name, AudioNdac, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = ESO_MIXREG_MPM_MOA2R; - strcpy(dip->un.e.member[2].label.name, AudioNmixerout); + strlcpy(dip->un.e.member[2].label.name, AudioNmixerout, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = ESO_MIXREG_MPM_MOREC; break; case ESO_SPATIALIZER: dip->mixer_class = ESO_OUTPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = ESO_SPATIALIZER_ENABLE; - strcpy(dip->label.name, AudioNspatial); + strlcpy(dip->label.name, AudioNspatial, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, "level"); + strlcpy(dip->un.v.units.name, "level", + sizeof dip->un.v.units.name); break; case ESO_SPATIALIZER_ENABLE: dip->mixer_class = ESO_OUTPUT_CLASS; dip->prev = ESO_SPATIALIZER; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "enable"); + strlcpy(dip->label.name, "enable", sizeof dip->label.name); dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; case ESO_OUTPUT_CLASS: dip->mixer_class = ESO_OUTPUT_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, + sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; break; case ESO_RECORD_MONITOR: dip->mixer_class = ESO_MONITOR_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; case ESO_MONITOR_CLASS: dip->mixer_class = ESO_MONITOR_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCmonitor); + strlcpy(dip->label.name, AudioCmonitor, + sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; break; case ESO_RECORD_VOL: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNrecord); + strlcpy(dip->label.name, AudioNrecord, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_RECORD_SOURCE: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 4; - strcpy(dip->un.e.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[0].label.name, AudioNmicrophone, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = ESO_MIXREG_ERS_MIC; - strcpy(dip->un.e.member[1].label.name, AudioNline); + strlcpy(dip->un.e.member[1].label.name, AudioNline, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = ESO_MIXREG_ERS_LINE; - strcpy(dip->un.e.member[2].label.name, AudioNcd); + strlcpy(dip->un.e.member[2].label.name, AudioNcd, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = ESO_MIXREG_ERS_CD; - strcpy(dip->un.e.member[3].label.name, AudioNmixerout); + strlcpy(dip->un.e.member[3].label.name, AudioNmixerout, + sizeof dip->un.e.member[3].label.name); dip->un.e.member[3].ord = ESO_MIXREG_ERS_MIXER; break; case ESO_DAC_REC_VOL: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_MIC_REC_VOL: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_LINE_REC_VOL: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_SYNTH_REC_VOL: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNfmsynth); + strlcpy(dip->label.name, AudioNfmsynth, + sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_MONO_REC_VOL: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "mono_in"); + strlcpy(dip->label.name, "mono_in", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 1; /* No lies */ - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_CD_REC_VOL: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_AUXB_REC_VOL: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "auxb"); + strlcpy(dip->label.name, "auxb", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case ESO_RECORD_CLASS: dip->mixer_class = ESO_RECORD_CLASS; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); dip->type = AUDIO_MIXER_CLASS; break; diff --git a/sys/dev/pci/fms.c b/sys/dev/pci/fms.c index 10d3bc3b270..921bfccb6fe 100644 --- a/sys/dev/pci/fms.c +++ b/sys/dev/pci/fms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fms.c,v 1.14 2002/11/19 18:40:17 jason Exp $ */ +/* $OpenBSD: fms.c,v 1.15 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: fms.c,v 1.5.4.1 2000/06/30 16:27:50 simonb Exp $ */ /*- @@ -465,49 +465,49 @@ fms_query_encoding(addr, fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return 0; case 1: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return 0; case 2: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; return 0; case 3: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return 0; case 4: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return 0; case 5: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return 0; case 6: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return 0; case 7: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; diff --git a/sys/dev/pci/fwlynx_pci.c b/sys/dev/pci/fwlynx_pci.c index e9f1fc70dca..5486e5b039f 100644 --- a/sys/dev/pci/fwlynx_pci.c +++ b/sys/dev/pci/fwlynx_pci.c @@ -90,7 +90,7 @@ fwlynx_pci_attach(struct device *parent, struct device *self, void *aux) pci_intr_handle_t ih; u_int32_t csr; - pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof devinfo); printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class)); psc->psc_sc.sc_dmat = pa->pa_dmat; diff --git a/sys/dev/pci/if_stge.c b/sys/dev/pci/if_stge.c index 8626d94b33f..2deddb1af0b 100644 --- a/sys/dev/pci/if_stge.c +++ b/sys/dev/pci/if_stge.c @@ -608,7 +608,7 @@ stge_attach(struct device *parent, struct device *self, void *aux) ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO); ifp = &sc->sc_arpcom.ac_if; - strcpy(ifp->if_xname, sc->sc_dev.dv_xname); + strlcpy(ifp->if_xname, sc->sc_dev.dv_xname, sizeof ifp->if_xname); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = stge_ioctl; diff --git a/sys/dev/pci/ncr.c b/sys/dev/pci/ncr.c index d3912d16865..edb0b51b323 100644 --- a/sys/dev/pci/ncr.c +++ b/sys/dev/pci/ncr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr.c,v 1.66 2003/02/11 19:20:27 mickey Exp $ */ +/* $OpenBSD: ncr.c,v 1.67 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: ncr.c,v 1.63 1997/09/23 02:39:15 perry Exp $ */ /************************************************************************** @@ -1466,7 +1466,7 @@ static void ncr_attach (pcici_t tag, int unit); #if 0 static char ident[] = - "\n$OpenBSD: ncr.c,v 1.66 2003/02/11 19:20:27 mickey Exp $\n"; + "\n$OpenBSD: ncr.c,v 1.67 2003/04/27 11:22:53 ho Exp $\n"; #endif static const u_long ncr_version = NCR_VERSION * 11 @@ -1570,7 +1570,7 @@ static struct scsi_device ncr_dev = static char *ncr_name (ncb_p np) { static char name[10]; - sprintf(name, "ncr%d", np->unit); + snprintf(name, sizeof name, "ncr%d", np->unit); return (name); } #endif diff --git a/sys/dev/pci/ncrstat.c b/sys/dev/pci/ncrstat.c index ac64d5132ae..9ddd305b338 100644 --- a/sys/dev/pci/ncrstat.c +++ b/sys/dev/pci/ncrstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncrstat.c,v 1.4 2002/03/14 03:16:06 millert Exp $ */ +/* $OpenBSD: ncrstat.c,v 1.5 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: ncrstat.c,v 1.7 1996/03/17 00:55:36 thorpej Exp $ */ /************************************************************************** @@ -939,7 +939,7 @@ static const char * sn (u_long a) if (!*s) return s; - sprintf (buffer, "%s:%d%c", s, m/4, 0); + snprintf (buffer, sizeof buffer, "%s:%d%c", s, m/4, 0); return (buffer); } diff --git a/sys/dev/pci/neo.c b/sys/dev/pci/neo.c index b88fdc2530e..1009d3e90d8 100644 --- a/sys/dev/pci/neo.c +++ b/sys/dev/pci/neo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neo.c,v 1.15 2003/03/21 19:38:36 jason Exp $ */ +/* $OpenBSD: neo.c,v 1.16 2003/04/27 11:22:53 ho Exp $ */ /* * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> @@ -770,49 +770,49 @@ neo_query_encoding(addr, fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; return (0); case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return (0); case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; diff --git a/sys/dev/pci/opl_eso.c b/sys/dev/pci/opl_eso.c index e5469e47516..6a0afd4bb35 100644 --- a/sys/dev/pci/opl_eso.c +++ b/sys/dev/pci/opl_eso.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opl_eso.c,v 1.3 2002/03/14 01:26:59 millert Exp $ */ +/* $OpenBSD: opl_eso.c,v 1.4 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: opl_eso.c,v 1.1 1999/07/12 15:13:31 kleink Exp $ */ /* @@ -102,7 +102,7 @@ opl_eso_attach(parent, self, aux) sc->ioh = esc->sc_sb_ioh; sc->iot = esc->sc_sb_iot; sc->offs = 0; - strcpy(sc->syn.name, "ESO "); + strlcpy(sc->syn.name, "ESO ", sizeof sc->syn.name); /*sc->spkrctl = 0; sc->spkrarg = 0;*/ diff --git a/sys/dev/pci/opl_yds.c b/sys/dev/pci/opl_yds.c index 5835c03a586..8210c3c9787 100644 --- a/sys/dev/pci/opl_yds.c +++ b/sys/dev/pci/opl_yds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opl_yds.c,v 1.3 2002/03/14 01:26:59 millert Exp $ */ +/* $OpenBSD: opl_yds.c,v 1.4 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD$ */ /* @@ -104,7 +104,7 @@ opl_yds_attach(parent, self, aux) sc->ioh = ssc->sc_opl_ioh; sc->iot = ssc->sc_opl_iot; sc->offs = 0; - strcpy(sc->syn.name, "DS-1 integrated "); + strlcpy(sc->syn.name, "DS-1 integrated ", sizeof sc->syn.name); opl_attach(sc); } diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index a7698ca5979..7112fdc8f2d 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.32 2003/02/28 15:26:23 mickey Exp $ */ +/* $OpenBSD: pci.c,v 1.33 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */ /* @@ -292,12 +292,14 @@ pciprint(aux, pnp) char devinfo[256]; if (pnp) { - pci_devinfo(pa->pa_id, pa->pa_class, 1, devinfo); + pci_devinfo(pa->pa_id, pa->pa_class, 1, devinfo, + sizeof devinfo); printf("%s at %s", devinfo, pnp); } printf(" dev %d function %d", pa->pa_device, pa->pa_function); if (!pnp) { - pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, + sizeof devinfo); printf(" %s", devinfo); } diff --git a/sys/dev/pci/pci_subr.c b/sys/dev/pci/pci_subr.c index 8e0778da787..0c5db1e82c7 100644 --- a/sys/dev/pci/pci_subr.c +++ b/sys/dev/pci/pci_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_subr.c,v 1.14 2002/04/07 19:21:40 tdeval Exp $ */ +/* $OpenBSD: pci_subr.c,v 1.15 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: pci_subr.c,v 1.19 1996/10/13 01:38:29 christos Exp $ */ /* @@ -301,10 +301,8 @@ pci_findvendor(pcireg_t id_reg) } void -pci_devinfo(id_reg, class_reg, showclass, cp) - pcireg_t id_reg, class_reg; - int showclass; - char *cp; +pci_devinfo(pcireg_t id_reg, pcireg_t class_reg, int showclass, char *cp, + size_t cp_max) { pci_vendor_id_t vendor; pci_product_id_t product; @@ -314,6 +312,7 @@ pci_devinfo(id_reg, class_reg, showclass, cp) pci_revision_t revision; const char *vendor_namep = NULL, *product_namep = NULL; const struct pci_class *classp, *subclassp; + size_t cp_len = 0; #ifdef PCIVERBOSE const struct pci_known_vendor *pkv; const struct pci_known_product *pkp; @@ -366,32 +365,39 @@ pci_devinfo(id_reg, class_reg, showclass, cp) } if (vendor_namep == NULL) - cp += sprintf(cp, "%svendor 0x%04x product 0x%04x", + snprintf(cp, cp_max, "%svendor 0x%04x product 0x%04x", unmatched, vendor, product); else if (product_namep != NULL) - cp += sprintf(cp, "\"%s %s\"", vendor_namep, product_namep); + snprintf(cp, cp_max, "\"%s %s\"", vendor_namep, product_namep); else - cp += sprintf(cp, "vendor \"%s\", unknown product 0x%x", + snprintf(cp, cp_max, "vendor \"%s\", unknown product 0x%x", vendor_namep, product); if (showclass && product_namep == NULL) { - cp += sprintf(cp, " ("); + strlcat(cp, " (", cp_max); + cp_len = strlen(cp); if (classp->name == NULL) - cp += sprintf(cp, + snprintf(cp + cp_len, cp_max - cp_len, "unknown class 0x%02x, subclass 0x%02x", class, subclass); - else { - cp += sprintf(cp, "class %s, ", classp->name); - if (subclassp == NULL || subclassp->name == NULL) - cp += sprintf(cp, "unknown subclass 0x%02x", - subclass); - else - cp += sprintf(cp, "subclass %s", - subclassp->name); - } + else if (subclassp == NULL || subclassp->name == NULL) + snprintf(cp + cp_len, cp_max - cp_len, + "class %s unknown subclass 0x%02x", classp->name, + subclass); + else + snprintf(cp + cp_len, cp_max - cp_len, + "class %s subclass %s", classp->name, + subclassp->name); #if 0 /* not very useful */ - cp += sprintf(cp, ", interface 0x%02x", interface); + cp_len = strlen(cp); + snprintf(cp + cp_len, cp_max - cp_len, + ", interface 0x%02x", interface); #endif - cp += sprintf(cp, ", rev 0x%02x)", revision); - } else - cp += sprintf(cp, " rev 0x%02x", revision); + cp_len = strlen(cp); + snprintf(cp + cp_len, cp_max - cp_len, + ", rev 0x%02x)", revision); + } else { + cp_len = strlen(cp); + snprintf(cp + cp_len, cp_max - cp_len, " rev 0x%02x", + revision); + } } diff --git a/sys/dev/pci/pciide.c b/sys/dev/pci/pciide.c index 30d9630229b..b513af827a8 100644 --- a/sys/dev/pci/pciide.c +++ b/sys/dev/pci/pciide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pciide.c,v 1.121 2003/04/20 21:09:28 grange Exp $ */ +/* $OpenBSD: pciide.c,v 1.122 2003/04/27 11:22:53 ho Exp $ */ /* $NetBSD: pciide.c,v 1.127 2001/08/03 01:31:08 tsutsui Exp $ */ /* @@ -711,7 +711,8 @@ pciide_attach(parent, self, aux) sc->sc_pp = pciide_lookup_product(pa->pa_id); if (sc->sc_pp == NULL) { sc->sc_pp = &default_product_desc; - pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, + sizeof devinfo); } sc->sc_pc = pa->pa_pc; diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index e3b6dfaf493..ff31a0fcf40 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcivar.h,v 1.29 2003/02/28 15:36:39 mickey Exp $ */ +/* $OpenBSD: pcivar.h,v 1.30 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: pcivar.h,v 1.23 1997/06/06 23:48:05 thorpej Exp $ */ /* @@ -193,7 +193,7 @@ int pci_matchbyid(struct pci_attach_args *, const struct pci_matchid *, int); * Helper functions for autoconfiguration. */ const char *pci_findvendor(pcireg_t); -void pci_devinfo(pcireg_t, pcireg_t, int, char *); +void pci_devinfo(pcireg_t, pcireg_t, int, char *, size_t); void set_pci_isa_bridge_callback(void (*)(void *), void *); const struct pci_quirkdata * pci_lookup_quirkdata(pci_vendor_id_t, pci_product_id_t); diff --git a/sys/dev/pci/sv.c b/sys/dev/pci/sv.c index 0b092dc7084..f183ffe674e 100644 --- a/sys/dev/pci/sv.c +++ b/sys/dev/pci/sv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sv.c,v 1.15 2003/02/11 19:20:28 mickey Exp $ */ +/* $OpenBSD: sv.c,v 1.16 2003/04/27 11:22:54 ho Exp $ */ /* * Copyright (c) 1998 Constantine Paul Sapuntzakis @@ -624,49 +624,49 @@ sv_query_encoding(addr, fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; return (0); case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return (0); case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -1050,8 +1050,8 @@ sv_query_devinfo(addr, dip) dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = dip->index; dip->next = dip->prev = AUDIO_MIXER_LAST; - strcpy(dip->label.name, - mixer_classes[dip->index]); + strlcpy(dip->label.name, mixer_classes[dip->index], + sizeof dip->label.name); return (0); } @@ -1062,7 +1062,7 @@ sv_query_devinfo(addr, dip) int idx = off / SV_DEVICES_PER_PORT; dip->mixer_class = ports[idx].class; - strcpy(dip->label.name, ports[idx].audio); + strlcpy(dip->label.name, ports[idx].audio, sizeof dip->label.name); if (!mute) { dip->type = AUDIO_MIXER_VALUE; @@ -1074,18 +1074,20 @@ sv_query_devinfo(addr, dip) else dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); - + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); + } else { dip->type = AUDIO_MIXER_ENUM; dip->prev = dip->index - 1; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; } @@ -1098,7 +1100,7 @@ sv_query_devinfo(addr, dip) dip->mixer_class = SV_RECORD_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = SV_RECORD_GAIN; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = ARRAY_SIZE(record_sources); @@ -1106,7 +1108,8 @@ sv_query_devinfo(addr, dip) { int idx; for (idx = 0; idx < ARRAY_SIZE(record_sources); idx++) { - strcpy(dip->un.e.member[idx].label.name, record_sources[idx].name); + strlcpy(dip->un.e.member[idx].label.name, record_sources[idx].name, + sizeof dip->un.e.member[idx].label.name); dip->un.e.member[idx].ord = record_sources[idx].idx; } } @@ -1116,30 +1119,32 @@ sv_query_devinfo(addr, dip) dip->mixer_class = SV_RECORD_CLASS; dip->prev = SV_RECORD_SOURCE; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "gain"); + strlcpy(dip->label.name, "gain", sizeof dip->label.name); dip->type = AUDIO_MIXER_VALUE; dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, sizeof dip->un.v.units.name); return (0); case SV_MIC_BOOST: dip->mixer_class = SV_RECORD_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, "micboost"); + strlcpy(dip->label.name, "micboost", sizeof dip->label.name); goto on_off; case SV_SRS_MODE: dip->mixer_class = SV_OUTPUT_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNspatial); + strlcpy(dip->label.name, AudioNspatial, sizeof dip->label.name); on_off: dip->type = AUDIO_MIXER_ENUM; dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNoff); + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNon); + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; return (0); } diff --git a/sys/dev/pci/yds.c b/sys/dev/pci/yds.c index 8631026a42b..50c1e695946 100644 --- a/sys/dev/pci/yds.c +++ b/sys/dev/pci/yds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yds.c,v 1.17 2003/02/25 20:14:34 tedu Exp $ */ +/* $OpenBSD: yds.c,v 1.18 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: yds.c,v 1.5 2001/05/21 23:55:04 minoura Exp $ */ /* @@ -668,7 +668,7 @@ yds_attach(parent, self, aux) mixer_ctrl_t ctl; int i, r; - pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo); + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof devinfo); /* Map register to memory */ if (pci_mapreg_map(pa, YDS_PCI_MBA, PCI_MAPREG_TYPE_MEM, 0, @@ -1113,49 +1113,49 @@ yds_query_encoding(addr, fp) { switch (fp->index) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; return (0); case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return (0); case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c index c72a1ec7367..73c144e70c3 100644 --- a/sys/dev/raidframe/rf_disks.c +++ b/sys/dev/raidframe/rf_disks.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_disks.c,v 1.8 2003/01/19 14:32:00 tdeval Exp $ */ +/* $OpenBSD: rf_disks.c,v 1.9 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: rf_disks.c,v 1.31 2000/06/02 01:17:14 oster Exp $ */ /* @@ -518,7 +518,8 @@ rf_AutoConfigureDisks(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, memcpy(&raidPtr->raid_cinfo[r][c].ci_label, ac->clabel, sizeof(*ac->clabel)); - sprintf(diskPtr->devname, "/dev/%s", + snprintf(diskPtr->devname, + sizeof diskPtr->devname, "/dev/%s", ac->devname); /* @@ -583,7 +584,8 @@ rf_AutoConfigureDisks(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, * Component must really be dead. */ disks[r][c].status = rf_ds_failed; - sprintf(disks[r][c].devname, "component%d", + snprintf(disks[r][c].devname, + sizeof disks[r][c].devname, "component%d", r * raidPtr->numCol + c); numFailuresThisRow++; } @@ -651,7 +653,7 @@ rf_ConfigureDisk(RF_Raid_t *raidPtr, char *buf, RF_RaidDisk_t *diskPtr, /* Strip off the newline. */ p[strlen(p) - 1] = '\0'; } - (void) strcpy(diskPtr->devname, p); + (void) strlcpy(diskPtr->devname, p, sizeof diskPtr->devname); proc = raidPtr->engine_thread; diff --git a/sys/dev/raidframe/rf_engine.c b/sys/dev/raidframe/rf_engine.c index e30e9f9f56f..d4c1dbd155f 100644 --- a/sys/dev/raidframe/rf_engine.c +++ b/sys/dev/raidframe/rf_engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_engine.c,v 1.14 2003/01/19 14:32:00 tdeval Exp $ */ +/* $OpenBSD: rf_engine.c,v 1.15 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: rf_engine.c,v 1.10 2000/08/20 16:51:03 thorpej Exp $ */ /* @@ -834,7 +834,6 @@ rf_DAGExecutionThread_pre(RF_ThreadArg_t arg) { RF_Raid_t *raidPtr; char raidname[16]; - int len; pid_t oldpid = lastpid; raidPtr = (RF_Raid_t *) arg; @@ -844,11 +843,7 @@ rf_DAGExecutionThread_pre(RF_ThreadArg_t arg) } lastpid = RF_ENGINE_PID + raidPtr->raidid - 1; - len = sprintf(&raidname[0], "raid%d", raidPtr->raidid); -#ifdef DIAGNOSTIC - if (len >= sizeof(raidname)) - panic("raidname expansion too long."); -#endif /* DIAGNOSTIC */ + snprintf(raidname, sizeof raidname, "raid%d", raidPtr->raidid); if (RF_CREATE_THREAD(raidPtr->engine_thread, rf_DAGExecutionThread, raidPtr, &raidname[0])) { diff --git a/sys/dev/raidframe/rf_general.h b/sys/dev/raidframe/rf_general.h index 12d40fa82b2..b530f6ee0a0 100644 --- a/sys/dev/raidframe/rf_general.h +++ b/sys/dev/raidframe/rf_general.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_general.h,v 1.5 2002/12/16 07:01:04 tdeval Exp $ */ +/* $OpenBSD: rf_general.h,v 1.6 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: rf_general.h,v 1.5 2000/03/03 02:04:48 oster Exp $ */ /* @@ -40,7 +40,7 @@ /* Error reporting and handling. */ #ifdef _KERNEL -#include <sys/systm.h> /* printf, sprintf, and friends. */ +#include <sys/systm.h> /* printf, snprintf, and friends. */ #endif #define RF_ERRORMSG(s) printf((s)) @@ -48,10 +48,11 @@ #define RF_ERRORMSG2(s,a,b) printf((s), (a), (b)) #define RF_ERRORMSG3(s,a,b,c) printf((s), (a), (b), (c)) -extern char rf_panicbuf[]; +extern char rf_panicbuf[2048]; #define RF_PANIC() \ do { \ - sprintf(rf_panicbuf, "RAIDframe error at line %d file %s", \ + snprintf(rf_panicbuf, sizeof rf_panicbuf, \ + "RAIDframe error at line %d file %s", \ __LINE__, __FILE__); \ panic(rf_panicbuf); \ } while (0) @@ -64,7 +65,8 @@ do { \ #define RF_ASSERT(_x_) \ do { \ if (!(_x_)) { \ - sprintf(rf_panicbuf, "RAIDframe error at line %d" \ + snprintf(rf_panicbuf, sizeof rf_panicbuf, \ + "RAIDframe error at line %d" \ " file %s (failed asserting %s)\n", __LINE__, \ __FILE__, #_x_); \ panic(rf_panicbuf); \ diff --git a/sys/dev/raidframe/rf_openbsdkintf.c b/sys/dev/raidframe/rf_openbsdkintf.c index a527f732dbe..75011e04b7c 100644 --- a/sys/dev/raidframe/rf_openbsdkintf.c +++ b/sys/dev/raidframe/rf_openbsdkintf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_openbsdkintf.c,v 1.22 2003/01/19 14:32:00 tdeval Exp $ */ +/* $OpenBSD: rf_openbsdkintf.c,v 1.23 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: rf_netbsdkintf.c,v 1.109 2001/07/27 03:30:07 oster Exp $ */ /*- @@ -438,7 +438,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_Calloc(raidPtrs[raidID], 1, sizeof (RF_Raid_t), (RF_Raid_t *)); @@ -1646,7 +1647,7 @@ raidinit(RF_Raid_t *raidPtr) rs->sc_flags |= RAIDF_INITED; /* XXX doesn't check bounds. */ - sprintf(rs->sc_xname, "raid%d", unit); + snprintf(rs->sc_xname, sizeof rs->sc_xname, "raid%d", unit); rs->sc_dkdev.dk_name = rs->sc_xname; @@ -2881,8 +2882,9 @@ rf_find_raid_components(void) 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; @@ -3213,7 +3215,7 @@ rf_create_configuration(RF_AutoConfig_t *ac, RF_Config_t *config, config->SUsPerRU = clabel->SUsPerRU; config->parityConfig = clabel->parityConfig; /* XXX... */ - strcpy(config->diskQueueType,"fifo"); + strlcpy(config->diskQueueType,"fifo", sizeof config->diskQueueType); config->maxOutstandingDiskReqs = clabel->maxOutstanding; config->layoutSpecificSize = 0; /* XXX ?? */ @@ -3222,8 +3224,9 @@ rf_create_configuration(RF_AutoConfig_t *ac, RF_Config_t *config, * row/col values will be in range due to the checks * in reasonable_label(). */ - strcpy(config->devnames[ac->clabel->row][ac->clabel->column], - ac->devname); + strlcpy(config->devnames[ac->clabel->row][ac->clabel->column], + ac->devname, + sizeof config->devnames[ac->clabel->row][ac->clabel->column]); ac = ac->next; } diff --git a/sys/dev/sbus/cs4231.c b/sys/dev/sbus/cs4231.c index 4360138d2be..c69480f8f55 100644 --- a/sys/dev/sbus/cs4231.c +++ b/sys/dev/sbus/cs4231.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4231.c,v 1.17 2003/03/27 17:39:05 jason Exp $ */ +/* $OpenBSD: cs4231.c,v 1.18 2003/04/27 11:22:54 ho Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -519,55 +519,55 @@ cs4231_query_encoding(addr, fp) switch (fp->index) { case 0: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = 0; break; case 1: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = 0; break; case 2: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; case 3: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; case 4: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = 0; break; case 5: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 6: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; break; case 8: - strcpy(fp->name, AudioEadpcm); + strlcpy(fp->name, AudioEadpcm, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ADPCM; fp->precision = 8; fp->flags = 0; @@ -1157,54 +1157,63 @@ cs4231_query_devinfo(addr, dip) dip->mixer_class = CSAUDIO_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CSAUDIO_MIC_MUTE; - strcpy(dip->label.name, AudioNmicrophone); + strlcpy(dip->label.name, AudioNmicrophone, + sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case CSAUDIO_DAC_LVL: /* dacout */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CSAUDIO_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CSAUDIO_DAC_MUTE; - strcpy(dip->label.name, AudioNdac); + strlcpy(dip->label.name, AudioNdac, + sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case CSAUDIO_LINE_IN_LVL: /* line */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CSAUDIO_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CSAUDIO_LINE_IN_MUTE; - strcpy(dip->label.name, AudioNline); + strlcpy(dip->label.name, AudioNline, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case CSAUDIO_CD_LVL: /* cd */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CSAUDIO_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CSAUDIO_CD_MUTE; - strcpy(dip->label.name, AudioNcd); + strlcpy(dip->label.name, AudioNcd, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case CSAUDIO_MONITOR_LVL: /* monitor level */ dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CSAUDIO_MONITOR_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CSAUDIO_MONITOR_MUTE; - strcpy(dip->label.name, AudioNmonitor); + strlcpy(dip->label.name, AudioNmonitor, + sizeof dip->label.name); dip->un.v.num_channels = 1; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case CSAUDIO_OUTPUT_LVL: dip->type = AUDIO_MIXER_VALUE; dip->mixer_class = CSAUDIO_OUTPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CSAUDIO_OUTPUT_MUTE; - strcpy(dip->label.name, AudioNoutput); + strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case CSAUDIO_LINE_IN_MUTE: dip->type = AUDIO_MIXER_ENUM; @@ -1244,11 +1253,13 @@ cs4231_query_devinfo(addr, dip) goto mute; mute: - strcpy(dip->label.name, AudioNmute); + strlcpy(dip->label.name, AudioNmute, sizeof dip->label.name); dip->un.e.num_mem = 2; - strcpy(dip->un.e.member[0].label.name, AudioNon); + strlcpy(dip->un.e.member[0].label.name, AudioNon, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = 0; - strcpy(dip->un.e.member[1].label.name, AudioNoff); + strlcpy(dip->un.e.member[1].label.name, AudioNoff, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = 1; break; case CSAUDIO_REC_LVL: /* record level */ @@ -1256,37 +1267,45 @@ cs4231_query_devinfo(addr, dip) dip->mixer_class = CSAUDIO_RECORD_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = CSAUDIO_RECORD_SOURCE; - strcpy(dip->label.name, AudioNrecord); + strlcpy(dip->label.name, AudioNrecord, sizeof dip->label.name); dip->un.v.num_channels = 2; - strcpy(dip->un.v.units.name, AudioNvolume); + strlcpy(dip->un.v.units.name, AudioNvolume, + sizeof dip->un.v.units.name); break; case CSAUDIO_RECORD_SOURCE: dip->type = AUDIO_MIXER_ENUM; dip->mixer_class = CSAUDIO_RECORD_CLASS; dip->prev = CSAUDIO_REC_LVL; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNsource); + strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); dip->un.e.num_mem = 4; - strcpy(dip->un.e.member[0].label.name, AudioNmicrophone); + strlcpy(dip->un.e.member[0].label.name, AudioNmicrophone, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = CSPORT_MICROPHONE; - strcpy(dip->un.e.member[1].label.name, AudioNline); + strlcpy(dip->un.e.member[1].label.name, AudioNline, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = CSPORT_LINEIN; - strcpy(dip->un.e.member[2].label.name, AudioNcd); + strlcpy(dip->un.e.member[2].label.name, AudioNcd, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = CSPORT_AUX1; - strcpy(dip->un.e.member[3].label.name, AudioNdac); + strlcpy(dip->un.e.member[3].label.name, AudioNdac, + sizeof dip->un.e.member[3].label.name); dip->un.e.member[3].ord = CSPORT_DAC; break; case CSAUDIO_OUTPUT: dip->type = AUDIO_MIXER_ENUM; dip->mixer_class = CSAUDIO_MONITOR_CLASS; dip->prev = dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioNoutput); + strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); dip->un.e.num_mem = 3; - strcpy(dip->un.e.member[0].label.name, AudioNspeaker); + strlcpy(dip->un.e.member[0].label.name, AudioNspeaker, + sizeof dip->un.e.member[0].label.name); dip->un.e.member[0].ord = CSPORT_SPEAKER; - strcpy(dip->un.e.member[1].label.name, AudioNline); + strlcpy(dip->un.e.member[1].label.name, AudioNline, + sizeof dip->un.e.member[1].label.name); dip->un.e.member[1].ord = CSPORT_LINEOUT; - strcpy(dip->un.e.member[2].label.name, AudioNheadphone); + strlcpy(dip->un.e.member[2].label.name, AudioNheadphone, + sizeof dip->un.e.member[2].label.name); dip->un.e.member[2].ord = CSPORT_HEADPHONE; break; case CSAUDIO_INPUT_CLASS: /* input class descriptor */ @@ -1294,28 +1313,30 @@ cs4231_query_devinfo(addr, dip) dip->mixer_class = CSAUDIO_INPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCinputs); + strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); break; case CSAUDIO_OUTPUT_CLASS: /* output class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = CSAUDIO_OUTPUT_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCoutputs); + strlcpy(dip->label.name, AudioCoutputs, + sizeof dip->label.name); break; case CSAUDIO_MONITOR_CLASS: /* monitor class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = CSAUDIO_MONITOR_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCmonitor); + strlcpy(dip->label.name, AudioCmonitor, + sizeof dip->label.name); break; case CSAUDIO_RECORD_CLASS: /* record class descriptor */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = CSAUDIO_RECORD_CLASS; dip->prev = AUDIO_MIXER_LAST; dip->next = AUDIO_MIXER_LAST; - strcpy(dip->label.name, AudioCrecord); + strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); break; default: err = ENXIO; diff --git a/sys/dev/tc/tc.c b/sys/dev/tc/tc.c index dec693d68c9..8f31502139d 100644 --- a/sys/dev/tc/tc.c +++ b/sys/dev/tc/tc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tc.c,v 1.13 2002/05/03 20:27:44 miod Exp $ */ +/* $OpenBSD: tc.c,v 1.14 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: tc.c,v 1.29 2001/11/13 06:26:10 lukem Exp $ */ /* @@ -52,7 +52,7 @@ struct cfdriver tc_cd = { int tcprint(void *, const char *); int tcsubmatch(struct device *, void *, void *); int tc_checkslot(tc_addr_t, char *); -void tc_devinfo(const char *, char *); +void tc_devinfo(const char *, char *, size_t); int tcmatch(parent, vcf, aux) @@ -189,7 +189,7 @@ tcprint(aux, pnp) char devinfo[256]; if (pnp) { - tc_devinfo(ta->ta_modname, devinfo); + tc_devinfo(ta->ta_modname, devinfo, sizeof devinfo); printf("%s at %s", devinfo, pnp); } printf(" slot %d offset 0x%lx", ta->ta_slot, @@ -304,9 +304,7 @@ struct tc_knowndev { #endif /* TCVERBOSE */ void -tc_devinfo(id, cp) - const char *id; - char *cp; +tc_devinfo(const char *id, char *cp, size_t cp_len) { const char *driver; #ifdef TCVERBOSE @@ -332,8 +330,8 @@ tc_devinfo(id, cp) tdp++; } if (driver != NULL) - cp += sprintf(cp, "%s (%s)", driver, description); + snprintf(cp, cp_len, "%s (%s)", driver, description); else #endif - cp += sprintf(cp, "%s", id); + snprintf(cp, cp_len, "%s", id); } diff --git a/sys/dev/tc/tcvar.h b/sys/dev/tc/tcvar.h index 4c563692a76..35a5db9bc30 100644 --- a/sys/dev/tc/tcvar.h +++ b/sys/dev/tc/tcvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcvar.h,v 1.10 2002/05/02 22:56:06 miod Exp $ */ +/* $OpenBSD: tcvar.h,v 1.11 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: tcvar.h,v 1.17 2000/06/04 19:15:15 cgd Exp $ */ /* @@ -140,7 +140,7 @@ struct tc_builtin { * Interrupt establishment functions. */ int tc_checkslot(tc_addr_t, char *); -void tc_devinfo(const char *, char *); +void tc_devinfo(const char *, char *, size_t); void tcattach(struct device *, struct device *, void *); const struct evcnt *tc_intr_evcnt(struct device *, void *); void tc_intr_establish(struct device *, void *, int, int (*)(void *), diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index 1af95547be8..649a2f7bb0f 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.13 2002/07/25 04:07:32 nate Exp $ */ +/* $OpenBSD: uaudio.c,v 1.14 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: uaudio.c,v 1.60 2002/05/18 15:14:39 kent Exp $ */ /* @@ -484,49 +484,49 @@ uaudio_query_encoding(void *addr, struct audio_encoding *fp) idx = fp->index; switch (idx) { case 0: - strcpy(fp->name, AudioEulinear); + strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = flags&HAS_8U ? 0 : AUDIO_ENCODINGFLAG_EMULATED; return (0); case 1: - strcpy(fp->name, AudioEmulaw); + strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = flags&HAS_MULAW ? 0 : AUDIO_ENCODINGFLAG_EMULATED; return (0); case 2: - strcpy(fp->name, AudioEalaw); + strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = flags&HAS_ALAW ? 0 : AUDIO_ENCODINGFLAG_EMULATED; return (0); case 3: - strcpy(fp->name, AudioEslinear); + strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = flags&HAS_8 ? 0 : AUDIO_ENCODINGFLAG_EMULATED; return (0); case 4: - strcpy(fp->name, AudioEslinear_le); + strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; return (0); case 5: - strcpy(fp->name, AudioEulinear_le); + strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 6: - strcpy(fp->name, AudioEslinear_be); + strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; return (0); case 7: - strcpy(fp->name, AudioEulinear_be); + strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; @@ -1375,40 +1375,46 @@ uaudio_query_devinfo(void *addr, mixer_devinfo_t *mi) mi->type = AUDIO_MIXER_CLASS; mi->mixer_class = nctls + UAC_OUTPUT; mi->next = mi->prev = AUDIO_MIXER_LAST; - strcpy(mi->label.name, AudioCoutputs); + strlcpy(mi->label.name, AudioCoutputs, + sizeof mi->label.name); return (0); case UAC_INPUT: mi->type = AUDIO_MIXER_CLASS; mi->mixer_class = nctls + UAC_INPUT; mi->next = mi->prev = AUDIO_MIXER_LAST; - strcpy(mi->label.name, AudioCinputs); + strlcpy(mi->label.name, AudioCinputs, + sizeof mi->label.name); return (0); case UAC_EQUAL: mi->type = AUDIO_MIXER_CLASS; mi->mixer_class = nctls + UAC_EQUAL; mi->next = mi->prev = AUDIO_MIXER_LAST; - strcpy(mi->label.name, AudioCequalization); + strlcpy(mi->label.name, AudioCequalization, + sizeof mi->label.name); return (0); default: return (ENXIO); } } mc = &sc->sc_ctls[n]; - strncpy(mi->label.name, mc->ctlname, MAX_AUDIO_DEV_LEN); + strlcpy(mi->label.name, mc->ctlname, sizeof mi->label.name); mi->mixer_class = mc->class; mi->next = mi->prev = AUDIO_MIXER_LAST; /* XXX */ switch (mc->type) { case MIX_ON_OFF: mi->type = AUDIO_MIXER_ENUM; mi->un.e.num_mem = 2; - strcpy(mi->un.e.member[0].label.name, AudioNoff); + strlcpy(mi->un.e.member[0].label.name, AudioNoff, + sizeof mi->un.e.member[0].label.name); mi->un.e.member[0].ord = 0; - strcpy(mi->un.e.member[1].label.name, AudioNon); + strlcpy(mi->un.e.member[1].label.name, AudioNon, + sizeof mi->un.e.member[1].label.name); mi->un.e.member[1].ord = 1; break; default: mi->type = AUDIO_MIXER_VALUE; - strncpy(mi->un.v.units.name, mc->ctlunit, MAX_AUDIO_DEV_LEN); + strlcpy(mi->un.v.units.name, mc->ctlunit, + sizeof mi->un.v.units.name); mi->un.v.num_channels = mc->nchan; mi->un.v.delta = mc->delta; break; diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c index 83d582ce726..5e9516e3515 100644 --- a/sys/dev/usb/umass.c +++ b/sys/dev/usb/umass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umass.c,v 1.21 2003/01/05 22:41:36 deraadt Exp $ */ +/* $OpenBSD: umass.c,v 1.22 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: umass.c,v 1.49 2001/01/21 18:56:38 augustss Exp $ */ /*- * Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>, @@ -864,7 +864,7 @@ USB_MATCH(umass) #elif defined(__NetBSD__) || defined(__OpenBSD__) struct umass_softc scs, *sc = &scs; memset(sc, 0, sizeof *sc); - strcpy(sc->sc_dev.dv_xname, "umass"); + strlcpy(sc->sc_dev.dv_xname, "umass", sizeof sc->sc_dev.dv_xname); #endif if (uaa->iface == NULL) @@ -3103,7 +3103,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) { @@ -3111,10 +3111,10 @@ 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 703d5f2515b..2ed030e3dbf 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_subr.c,v 1.22 2002/07/25 02:18:11 nate Exp $ */ +/* $OpenBSD: usb_subr.c,v 1.23 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: usb_subr.c,v 1.87 2001/08/15 00:04:59 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -269,13 +269,15 @@ usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p, int usedev) } #endif if (vendor != NULL && *vendor) - strcpy(v, vendor); + strlcpy(v, vendor, USB_MAX_STRING_LEN); /* XXX */ else - sprintf(v, "vendor 0x%04x", UGETW(udd->idVendor)); + snprintf(v, USB_MAX_STRING_LEN, "vendor 0x%04x", /* XXX */ + UGETW(udd->idVendor)); if (product != NULL && *product) - strcpy(p, product); + strlcpy(p, product, USB_MAX_STRING_LEN); /* XXX */ else - sprintf(p, "product 0x%04x", UGETW(udd->idProduct)); + snprintf(p, USB_MAX_STRING_LEN, "product 0x%04x", /* XXX */ + UGETW(udd->idProduct)); } int diff --git a/sys/dev/wscons/wsdisplay_compat_usl.c b/sys/dev/wscons/wsdisplay_compat_usl.c index 1064e319e6c..f06275cdcb4 100644 --- a/sys/dev/wscons/wsdisplay_compat_usl.c +++ b/sys/dev/wscons/wsdisplay_compat_usl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplay_compat_usl.c,v 1.11 2002/03/14 03:16:08 millert Exp $ */ +/* $OpenBSD: wsdisplay_compat_usl.c,v 1.12 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: wsdisplay_compat_usl.c,v 1.12 2000/03/23 07:01:47 thorpej Exp $ */ /* @@ -350,7 +350,7 @@ wsdisplay_usl_ioctl1(sc, cmd, data, flag, p) #ifdef WSDISPLAY_COMPAT_PCVT case VGAPCVTID: #define id ((struct pcvtid *)data) - strcpy(id->name, "pcvt"); + strlcpy(id->name, "pcvt", sizeof id->name); id->rmajor = 3; id->rminor = 32; #undef id diff --git a/sys/dev/wscons/wsemul_vt100_subr.c b/sys/dev/wscons/wsemul_vt100_subr.c index 802040b632c..9a9dc021fd1 100644 --- a/sys/dev/wscons/wsemul_vt100_subr.c +++ b/sys/dev/wscons/wsemul_vt100_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsemul_vt100_subr.c,v 1.8 2002/03/14 01:27:03 millert Exp $ */ +/* $OpenBSD: wsemul_vt100_subr.c,v 1.9 2003/04/27 11:22:54 ho Exp $ */ /* $NetBSD: wsemul_vt100_subr.c,v 1.7 2000/04/28 21:56:16 mycroft Exp $ */ /* @@ -343,7 +343,7 @@ wsemul_vt100_handle_csi(edp, c) wsdisplay_emulinput(edp->cbcookie, "\033P2$u", 5); for (i = 0; i < edp->ncols; i++) if (edp->tabs[i]) { - n = sprintf(buf, "%s%d", + n = snprintf(buf, sizeof buf, "%s%d", (ps ? "/" : ""), i + 1); wsdisplay_emulinput(edp->cbcookie, buf, n); @@ -566,7 +566,7 @@ wsemul_vt100_handle_csi(edp, c) row = ROWS_ABOVE; else row = edp->crow; - n = sprintf(buf, "\033[%d;%dR", + n = snprintf(buf, sizeof buf, "\033[%d;%dR", row + 1, edp->ccol + 1); wsdisplay_emulinput(edp->cbcookie, buf, n); } |