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 /sys/dev/usb | |
parent | c9c7d16545b1bfad4519f491aa113a57ab7c7b2d (diff) |
strcpy/sprintf cleanup of sys/dev. miod@, deraadt@ says to commit.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/uaudio.c | 38 | ||||
-rw-r--r-- | sys/dev/usb/umass.c | 10 | ||||
-rw-r--r-- | sys/dev/usb/usb_subr.c | 12 |
3 files changed, 34 insertions, 26 deletions
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 |