diff options
| author | christos <christos@NetBSD.org> | 2014-03-25 16:19:13 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2014-03-25 16:19:13 +0000 |
| commit | 95e4dc1ef53e03d32c17523bf0c9d85a894cb59b (patch) | |
| tree | 82eb67bff76e19525098b11097af66534c183955 /sys/dev | |
| parent | 9f98c16f37b75c9db25349ca8eefba4665d21e63 (diff) | |
kill sprintf
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ata/ata_raid_intel.c | 6 | ||||
| -rw-r--r-- | sys/dev/ata/ata_raid_jmicron.c | 6 | ||||
| -rw-r--r-- | sys/dev/ata/ata_raid_nvidia.c | 6 | ||||
| -rw-r--r-- | sys/dev/ata/ata_raid_via.c | 18 | ||||
| -rw-r--r-- | sys/dev/firmload.c | 11 | ||||
| -rw-r--r-- | sys/dev/ic/ncr53c9xvar.h | 9 | ||||
| -rw-r--r-- | sys/dev/ic/sunscpal.c | 6 | ||||
| -rw-r--r-- | sys/dev/pci/cxgb/cxgb_l2t.c | 4 | ||||
| -rw-r--r-- | sys/dev/pci/cxgb/cxgb_offload.c | 19 | ||||
| -rw-r--r-- | sys/dev/pci/hdaudio/hdafg.c | 10 | ||||
| -rw-r--r-- | sys/dev/pci/if_kse.c | 7 | ||||
| -rw-r--r-- | sys/dev/pci/if_wm.c | 7 | ||||
| -rw-r--r-- | sys/dev/pci/ixgbe/ixv.c | 8 | ||||
| -rw-r--r-- | sys/dev/pci/n8/common/api/n8_callback.c | 4 | ||||
| -rw-r--r-- | sys/dev/pci/n8/common/api/n8_daemon_sks.c | 18 | ||||
| -rw-r--r-- | sys/dev/pci/n8/common/api/n8_sks.c | 6 | ||||
| -rw-r--r-- | sys/dev/pci/n8/common/api/n8_system.c | 13 | ||||
| -rw-r--r-- | sys/dev/pci/n8/include_public/n8_pub_service.h | 2 | ||||
| -rw-r--r-- | sys/dev/pci/n8/include_public/n8_pub_sks.h | 2 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_disks.c | 7 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_general.h | 4 |
21 files changed, 90 insertions, 83 deletions
diff --git a/sys/dev/ata/ata_raid_intel.c b/sys/dev/ata/ata_raid_intel.c index a8a696a12f3..60f91faf6b0 100644 --- a/sys/dev/ata/ata_raid_intel.c +++ b/sys/dev/ata/ata_raid_intel.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_intel.c,v 1.6 2010/07/06 18:09:04 bsh Exp $ */ +/* $NetBSD: ata_raid_intel.c,v 1.7 2014/03/25 16:19:13 christos Exp $ */ /*- * Copyright (c) 2000-2008 Søren Schmidt <sos@FreeBSD.org> @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.6 2010/07/06 18:09:04 bsh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.7 2014/03/25 16:19:13 christos Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -79,7 +79,7 @@ ata_raid_intel_type(int type) case INTEL_T_RAID5: return "RAID5"; default: - sprintf(buffer, "UNKNOWN 0x%02x", type); + snprintf(buffer, sizeof(buffer), "UNKNOWN 0x%02x", type); return buffer; } } diff --git a/sys/dev/ata/ata_raid_jmicron.c b/sys/dev/ata/ata_raid_jmicron.c index afbddb95f0a..4f0b6b55583 100644 --- a/sys/dev/ata/ata_raid_jmicron.c +++ b/sys/dev/ata/ata_raid_jmicron.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_jmicron.c,v 1.4 2009/05/11 17:14:31 cegger Exp $ */ +/* $NetBSD: ata_raid_jmicron.c,v 1.5 2014/03/25 16:19:13 christos Exp $ */ /*- * Copyright (c) 2000-2008 Søren Schmidt <sos@FreeBSD.org> @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.4 2009/05/11 17:14:31 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.5 2014/03/25 16:19:13 christos Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -82,7 +82,7 @@ ata_raid_jmicron_type(int type) case JM_T_JBOD: return "JBOD"; default: - sprintf(buffer, "UNKNOWN 0x%02x", type); + snprintf(buffer, sizeof(buffer), "UNKNOWN 0x%02x", type); return buffer; } } diff --git a/sys/dev/ata/ata_raid_nvidia.c b/sys/dev/ata/ata_raid_nvidia.c index 64e4bd87d29..7e811d5a29c 100644 --- a/sys/dev/ata/ata_raid_nvidia.c +++ b/sys/dev/ata/ata_raid_nvidia.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_nvidia.c,v 1.1 2008/08/20 15:00:34 tacha Exp $ */ +/* $NetBSD: ata_raid_nvidia.c,v 1.2 2014/03/25 16:19:13 christos Exp $ */ /*- * Copyright (c) 2000 - 2008 Søren Schmidt <sos@FreeBSD.org> @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.1 2008/08/20 15:00:34 tacha Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.2 2014/03/25 16:19:13 christos Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -76,7 +76,7 @@ ata_raid_nvidia_type(int type) case NV_T_RAID5: return "RAID5"; case NV_T_RAID01: return "RAID0+1"; default: - sprintf(buffer, "UNKNOWN 0x%02x", type); + snprintf(buffer, sizeof(buffer), "UNKNOWN 0x%02x", type); return buffer; } } diff --git a/sys/dev/ata/ata_raid_via.c b/sys/dev/ata/ata_raid_via.c index 2187d6eb921..c0fe8c9fddf 100644 --- a/sys/dev/ata/ata_raid_via.c +++ b/sys/dev/ata/ata_raid_via.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_via.c,v 1.6 2008/09/19 16:49:27 christos Exp $ */ +/* $NetBSD: ata_raid_via.c,v 1.7 2014/03/25 16:19:13 christos Exp $ */ /*- * Copyright (c) 2000,2001,2002 Søren Schmidt <sos@FreeBSD.org> @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_raid_via.c,v 1.6 2008/09/19 16:49:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_via.c,v 1.7 2014/03/25 16:19:13 christos Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -71,13 +71,13 @@ ata_raid_via_type(int type) static char buffer[16]; switch (type) { - case VIA_T_RAID0: return "RAID0"; - case VIA_T_RAID1: return "RAID1"; - case VIA_T_RAID5: return "RAID5"; - case VIA_T_RAID01: return "RAID0+1"; - case VIA_T_SPAN: return "SPAN"; - default: - sprintf(buffer, "UNKNOWN 0x%02x", type); + case VIA_T_RAID0: return "RAID0"; + case VIA_T_RAID1: return "RAID1"; + case VIA_T_RAID5: return "RAID5"; + case VIA_T_RAID01: return "RAID0+1"; + case VIA_T_SPAN: return "SPAN"; + default: + snprintf(buffer, sizeof(buffer), "UNKNOWN 0x%02x", type); return buffer; } } diff --git a/sys/dev/firmload.c b/sys/dev/firmload.c index 0e2d99e1bf9..79df7681f02 100644 --- a/sys/dev/firmload.c +++ b/sys/dev/firmload.c @@ -1,4 +1,4 @@ -/* $NetBSD: firmload.c,v 1.18 2014/02/25 18:30:09 pooka Exp $ */ +/* $NetBSD: firmload.c,v 1.19 2014/03/25 16:19:13 christos Exp $ */ /*- * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.18 2014/02/25 18:30:09 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.19 2014/03/25 16:19:13 christos Exp $"); /* * The firmload API provides an interface for device drivers to access @@ -185,11 +185,8 @@ firmware_path_next(const char *drvname, const char *imgname, char *pnbuf, prefix++; *prefixp = prefix; - /* - * This sprintf() is safe because of the maxprefix calculation - * performed above. - */ - sprintf(&pnbuf[i], "/%s/%s", drvname, imgname); + KASSERT(MAXPATHLEN >= i); + snprintf(pnbuf + i, MAXPATHLEN - i, "/%s/%s", drvname, imgname); return (pnbuf); } diff --git a/sys/dev/ic/ncr53c9xvar.h b/sys/dev/ic/ncr53c9xvar.h index 38a9ca0f87f..b35fc7cb4be 100644 --- a/sys/dev/ic/ncr53c9xvar.h +++ b/sys/dev/ic/ncr53c9xvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ncr53c9xvar.h,v 1.55 2011/07/31 18:39:00 jakllsch Exp $ */ +/* $NetBSD: ncr53c9xvar.h,v 1.56 2014/03/25 16:19:13 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -130,9 +130,10 @@ struct ncr53c9x_ecb { #if NCR53C9X_DEBUG > 1 #define ECB_TRACE(ecb, msg, a, b) do { \ const char *f = "[" msg "]"; \ - int n = strlen((ecb)->trace); \ - if (n < (sizeof((ecb)->trace)-100)) \ - sprintf((ecb)->trace + n, f, a, b); \ + size_t n = strlen((ecb)->trace); \ + if (n >= (sizeof((ecb)->trace)-100)) \ + break; \ + 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/sunscpal.c b/sys/dev/ic/sunscpal.c index f2f00453897..847ffdfb12a 100644 --- a/sys/dev/ic/sunscpal.c +++ b/sys/dev/ic/sunscpal.c @@ -1,4 +1,4 @@ -/* $NetBSD: sunscpal.c,v 1.25 2009/11/23 02:13:46 rmind Exp $ */ +/* $NetBSD: sunscpal.c,v 1.26 2014/03/25 16:19:13 christos Exp $ */ /* * Copyright (c) 2001 Matthew Fredette @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sunscpal.c,v 1.25 2009/11/23 02:13:46 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunscpal.c,v 1.26 2014/03/25 16:19:13 christos Exp $"); #include "opt_ddb.h" @@ -725,7 +725,6 @@ sunscpal_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg) { struct scsipi_xfer *xs; - struct scsipi_periph *periph; struct sunscpal_softc *sc; struct sunscpal_req *sr; int s, i, flags; @@ -735,7 +734,6 @@ sunscpal_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, switch (req) { case ADAPTER_REQ_RUN_XFER: xs = arg; - periph = xs->xs_periph; flags = xs->xs_control; if (flags & XS_CTL_DATA_UIO) diff --git a/sys/dev/pci/cxgb/cxgb_l2t.c b/sys/dev/pci/cxgb/cxgb_l2t.c index 9305313948d..8dafeb6c3e4 100644 --- a/sys/dev/pci/cxgb/cxgb_l2t.c +++ b/sys/dev/pci/cxgb/cxgb_l2t.c @@ -28,7 +28,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cxgb_l2t.c,v 1.2 2013/01/23 23:31:26 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cxgb_l2t.c,v 1.3 2014/03/25 16:19:14 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -635,7 +635,7 @@ l2t_seq_show(struct seq_file *seq, void *v) struct l2t_entry *e = v; mtx_lock(&e->lock); - sprintf(ip, "%u.%u.%u.%u", NIPQUAD(e->addr)); + snprintf(ip, sizeof(ip), "%u.%u.%u.%u", NIPQUAD(e->addr)); seq_printf(seq, "%-5u %-15s %02x:%02x:%02x:%02x:%02x:%02x %4d" " %3u %c %7u %4u %s\n", e->idx, ip, e->dmac[0], e->dmac[1], e->dmac[2], diff --git a/sys/dev/pci/cxgb/cxgb_offload.c b/sys/dev/pci/cxgb/cxgb_offload.c index c5cf9c2673d..29004e7b359 100644 --- a/sys/dev/pci/cxgb/cxgb_offload.c +++ b/sys/dev/pci/cxgb/cxgb_offload.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cxgb_offload.c,v 1.2 2011/05/18 01:01:59 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cxgb_offload.c,v 1.3 2014/03/25 16:19:14 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1565,7 +1565,7 @@ offload_info_read_proc(char *buf, char **start, off_t offset, struct tid_info *t = &d->tid_maps; int len; - len = sprintf(buf, "TID range: 0..%d, in use: %u\n" + len = snprintf(buf, length, "TID range: 0..%d, in use: %u\n" "STID range: %d..%d, in use: %u\n" "ATID range: %d..%d, in use: %u\n" "MSS: %u\n", @@ -1605,20 +1605,25 @@ offload_devices_read_proc(char *buf, char **start, off_t offset, struct toedev *dev; struct net_device *ndev; - len = sprintf(buf, "Device Interfaces\n"); + len = snprintf(buf, length, "Device Interfaces\n"); mtx_lock(&cxgb_db_lock); TAILQ_FOREACH(dev, &ofld_dev_list, ofld_entry) { - len += sprintf(buf + len, "%-16s", dev->name); + if (len >= length) + break; + len += snprintf(buf + len, length - len, "%-16s", dev->name); read_lock(&dev_base_lock); for (ndev = dev_base; ndev; ndev = ndev->next) { - if (TOEDEV(ndev) == dev) - len += sprintf(buf + len, " %s", ndev->name); + if (TOEDEV(ndev) == dev) { + if (len >= length) + break; + len += snprintf(buf + len, length - len, " %s", ndev->name); + } } read_unlock(&dev_base_lock); - len += sprintf(buf + len, "\n"); if (len >= length) break; + len += snprintf(buf + len, length - len, "\n"); } mtx_unlock(&cxgb_db_lock); diff --git a/sys/dev/pci/hdaudio/hdafg.c b/sys/dev/pci/hdaudio/hdafg.c index 8725ff80a3f..d4be2bc6049 100644 --- a/sys/dev/pci/hdaudio/hdafg.c +++ b/sys/dev/pci/hdaudio/hdafg.c @@ -1,4 +1,4 @@ -/* $NetBSD: hdafg.c,v 1.18 2013/10/16 18:13:00 christos Exp $ */ +/* $NetBSD: hdafg.c,v 1.19 2014/03/25 16:19:14 christos Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd <support@precedence.co.uk> @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.18 2013/10/16 18:13:00 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.19 2014/03/25 16:19:14 christos Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -2944,7 +2944,8 @@ hdafg_build_mixers(struct hdafg_softc *sc) if (sc->sc_assocs[i].as_dir != HDAUDIO_PINDIR_OUT) continue; mx[index].mx_di.un.s.member[j].mask = 1 << i; - sprintf(mx[index].mx_di.un.s.member[j].label.name, + snprintf(mx[index].mx_di.un.s.member[j].label.name, + sizeof(mx[index].mx_di.un.s.member[j].label.name), "%s%02X", hdafg_assoc_type_string(&sc->sc_assocs[i]), i); ++j; @@ -2967,7 +2968,8 @@ hdafg_build_mixers(struct hdafg_softc *sc) if (sc->sc_assocs[i].as_dir != HDAUDIO_PINDIR_IN) continue; mx[index].mx_di.un.s.member[j].mask = 1 << i; - sprintf(mx[index].mx_di.un.s.member[j].label.name, + snprintf(mx[index].mx_di.un.s.member[j].label.name, + sizeof(mx[index].mx_di.un.s.member[j].label.name), "%s%02X", hdafg_assoc_type_string(&sc->sc_assocs[i]), i); ++j; diff --git a/sys/dev/pci/if_kse.c b/sys/dev/pci/if_kse.c index 724d24378b9..99181415f8b 100644 --- a/sys/dev/pci/if_kse.c +++ b/sys/dev/pci/if_kse.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_kse.c,v 1.25 2013/11/08 06:20:48 nisimura Exp $ */ +/* $NetBSD: if_kse.c,v 1.26 2014/03/25 16:19:13 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.25 2013/11/08 06:20:48 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.26 2014/03/25 16:19:13 christos Exp $"); #include <sys/param.h> @@ -530,7 +530,8 @@ kse_attach(device_t parent, device_t self, void *aux) int p = (sc->sc_chip == 0x8842) ? 3 : 1; for (i = 0; i < p; i++) { struct ksext *ee = &sc->sc_ext; - sprintf(ee->evcntname[i], "%s.%d", device_xname(sc->sc_dev), i+1); + snprintf(ee->evcntname[i], sizeof(ee->evcntname[i]), + "%s.%d", device_xname(sc->sc_dev), i+1); evcnt_attach_dynamic(&ee->pev[i][0], EVCNT_TYPE_MISC, NULL, ee->evcntname[i], "RxLoPriotyByte"); evcnt_attach_dynamic(&ee->pev[i][1], EVCNT_TYPE_MISC, diff --git a/sys/dev/pci/if_wm.c b/sys/dev/pci/if_wm.c index b233e64ee86..a4e9599af67 100644 --- a/sys/dev/pci/if_wm.c +++ b/sys/dev/pci/if_wm.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.266 2014/01/07 13:14:39 msaitoh Exp $ */ +/* $NetBSD: if_wm.c,v 1.267 2014/03/25 16:19:13 christos Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.266 2014/01/07 13:14:39 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.267 2014/03/25 16:19:13 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -2094,7 +2094,8 @@ wm_attach(device_t parent, device_t self, void *aux) NULL, xname, "txtsopain"); for (i = 0; i < WM_NTXSEGS; i++) { - sprintf(wm_txseg_evcnt_names[i], "txseg%d", i); + snprintf(wm_txseg_evcnt_names[i], + sizeof(wm_txseg_evcnt_names[i]), "txseg%d", i); evcnt_attach_dynamic(&sc->sc_ev_txseg[i], EVCNT_TYPE_MISC, NULL, xname, wm_txseg_evcnt_names[i]); } diff --git a/sys/dev/pci/ixgbe/ixv.c b/sys/dev/pci/ixgbe/ixv.c index b03fee0918b..afc13eabdfb 100644 --- a/sys/dev/pci/ixgbe/ixv.c +++ b/sys/dev/pci/ixgbe/ixv.c @@ -31,7 +31,7 @@ ******************************************************************************/ /*$FreeBSD: src/sys/dev/ixgbe/ixv.c,v 1.2 2011/03/23 13:10:15 jhb Exp $*/ -/*$NetBSD: ixv.c,v 1.1 2011/08/12 21:55:29 dyoung Exp $*/ +/*$NetBSD: ixv.c,v 1.2 2014/03/25 16:19:14 christos Exp $*/ #include "opt_inet.h" @@ -269,9 +269,9 @@ ixv_probe(device_t dev) ((pci_subdevice_id == ent->subdevice_id) || (ent->subdevice_id == 0))) { - sprintf(adapter_name, "%s, Version - %s", - ixv_strings[ent->index], - ixv_driver_version); + snprintf(adapter_name, sizeof(adapter_name), + "%s, Version - %s", ixv_strings[ent->index], + ixv_driver_version); device_set_desc_copy(dev, adapter_name); return (0); } diff --git a/sys/dev/pci/n8/common/api/n8_callback.c b/sys/dev/pci/n8/common/api/n8_callback.c index 312cb80b255..5a52bf881b8 100644 --- a/sys/dev/pci/n8/common/api/n8_callback.c +++ b/sys/dev/pci/n8/common/api/n8_callback.c @@ -32,7 +32,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -static char const n8_id[] = "$Id: n8_callback.c,v 1.1 2008/10/30 12:02:14 darran Exp $"; +static char const n8_id[] = "$Id: n8_callback.c,v 1.2 2014/03/25 16:19:14 christos Exp $"; /*****************************************************************************/ /** @file n8_callback.c * @brief Routines for implementing the API callbacks. @@ -188,7 +188,7 @@ N8_Status_t n8_callbackThread(N8_CallbackData_t *callbackData_p) recalc_sigpending(current); /* set name of this process (max 15 chars + 0 !) */ - sprintf(current->comm, "NSP2000 Thread"); + strcpy(current->comm, "NSP2000 Thread"); #endif while (callbackData_p->n8_thread == TRUE) diff --git a/sys/dev/pci/n8/common/api/n8_daemon_sks.c b/sys/dev/pci/n8/common/api/n8_daemon_sks.c index 52ca84f98ec..84e779487e8 100644 --- a/sys/dev/pci/n8/common/api/n8_daemon_sks.c +++ b/sys/dev/pci/n8/common/api/n8_daemon_sks.c @@ -32,7 +32,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -static char const n8_id[] = "$Id: n8_daemon_sks.c,v 1.1 2008/10/30 12:02:14 darran Exp $"; +static char const n8_id[] = "$Id: n8_daemon_sks.c,v 1.2 2014/03/25 16:19:14 christos Exp $"; /*****************************************************************************/ /** @file n8_daemon_sks.c * @brief This file implements the user side of the daemon's SKS @@ -233,8 +233,7 @@ N8_Status_t n8_daemon_sks_write(N8_SKSKeyHandle_t *sks_key_p, * we don't terminate it with '/'. This is because on BSDi * you can't create a directory whose name appended with '/' */ - sprintf(sub_dir, "%s%i", - SKS_KEY_NODE_PATH, + snprintf(sub_dir, sizeof(sub_dir), "%s%i", SKS_KEY_NODE_PATH, sks_key_p->unitID); if ((dir_p = opendir(sub_dir)) == NULL) @@ -258,7 +257,7 @@ N8_Status_t n8_daemon_sks_write(N8_SKSKeyHandle_t *sks_key_p, } /* build full path name for key handle file */ - sprintf(key_entry, "%s%i/%s", + snprintf(key_entry, sizeof(key_entry), "%s%i/%s", SKS_KEY_NODE_PATH, sks_key_p->unitID, key_entry_name); @@ -438,8 +437,8 @@ N8_Status_t n8_daemon_sks_init(N8_Unit_t targetSKS, /* Open the SKS entry directory. Read all the key files and * allocate descriptor space for them. */ - sprintf(sks_entry_name, "%s%i/", SKS_KEY_NODE_PATH, - targetSKS); + snprintf(sks_entry_name, sizeof(sks_entry_name), "%s%i/", + SKS_KEY_NODE_PATH, targetSKS); DBG(("Target sks dev node is '%s'.\n\n", sks_entry_name)); @@ -461,7 +460,7 @@ N8_Status_t n8_daemon_sks_init(N8_Unit_t targetSKS, if ((strcmp(dirent_p->d_name, ".") != 0) && (strcmp(dirent_p->d_name, "..") != 0)) { - sprintf(sks_entry, "%s%s", sks_entry_name, + snprintf(sks_entry, sizeof(sks_entry), "%s%s", sks_entry_name, dirent_p->d_name); ret = n8_daemon_sks_read(&keyHandle, @@ -521,7 +520,8 @@ N8_Status_t n8_daemon_sks_reset(N8_Unit_t targetSKS) N8_Status_t ret = N8_STATUS_OK; DBG(("Reset :\n")); - sprintf(key_entry, "%s%i/", SKS_KEY_NODE_PATH, targetSKS); + snprintf(key_entry, sizeof(key_entry), "%s%i/", + SKS_KEY_NODE_PATH, targetSKS); /* Find out which, if any, key entries exist. Then blast 'em. */ DBG(("Resetting SKS %i.\n", targetSKS)); @@ -557,7 +557,7 @@ N8_Status_t n8_daemon_sks_reset(N8_Unit_t targetSKS) } DBG(("%s : \n", dirent_p->d_name)); - sprintf(key_entry_path, "%s%i/%s", + snprintf(key_entry_path, sizeof(key_entry_path), "%s%i/%s", SKS_KEY_NODE_PATH, targetSKS, dirent_p->d_name); diff --git a/sys/dev/pci/n8/common/api/n8_sks.c b/sys/dev/pci/n8/common/api/n8_sks.c index a5604214d07..708914d84e5 100644 --- a/sys/dev/pci/n8/common/api/n8_sks.c +++ b/sys/dev/pci/n8/common/api/n8_sks.c @@ -32,7 +32,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -static char const n8_id[] = "$Id: n8_sks.c,v 1.2 2011/08/01 12:28:54 mbalmer Exp $"; +static char const n8_id[] = "$Id: n8_sks.c,v 1.3 2014/03/25 16:19:14 christos Exp $"; /*****************************************************************************/ /** @file SKS_Management_Interface * @brief Implementation for the SKS Management Interface. @@ -379,7 +379,7 @@ void n8_printSKSKeyHandle(const N8_SKSKeyHandle_t *keyHandle_p) * The given key handle pointer is valid. *****************************************************************************/ N8_Status_t N8_SKSDisplay(N8_SKSKeyHandle_t *keyHandle_p, - char *display_string_p) + char *display_string_p, size_t len) { if (keyHandle_p == NULL) { @@ -391,7 +391,7 @@ N8_Status_t N8_SKSDisplay(N8_SKSKeyHandle_t *keyHandle_p, return N8_INVALID_PARAMETER; } - sprintf(display_string_p, + snprintf(display_string_p, len, "Key Handle:\n" "\tKey Type %08x\n" "\tKey Length %08x\n" diff --git a/sys/dev/pci/n8/common/api/n8_system.c b/sys/dev/pci/n8/common/api/n8_system.c index 20158c16dbc..7b1116a0387 100644 --- a/sys/dev/pci/n8/common/api/n8_system.c +++ b/sys/dev/pci/n8/common/api/n8_system.c @@ -32,7 +32,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -static char const n8_id[] = "$Id: n8_system.c,v 1.1 2008/10/30 12:02:15 darran Exp $"; +static char const n8_id[] = "$Id: n8_system.c,v 1.2 2014/03/25 16:19:14 christos Exp $"; /*****************************************************************************/ /** @file n8_system.c * @brief Implements the API call N8_GetSystemParameter, which allows users to @@ -71,7 +71,7 @@ static N8_Status_t setHWrevision(N8_Buffer_t *value_p); static N8_Status_t setSWversion(N8_Buffer_t *value_p); static N8_Status_t setContextSize(N8_Buffer_t *value_p); static N8_Status_t setSKSsize(N8_Buffer_t *value_p); -static N8_Status_t setSWversionText(N8_Buffer_t *value_p); +static N8_Status_t setSWversionText(N8_Buffer_t *value_p, size_t value_l); static N8_Status_t setFD(N8_Buffer_t *value_p); static N8_Status_t setInitInfo(N8_Buffer_t *value_p); @@ -104,7 +104,8 @@ extern NSPdriverInfo_t nspDriverInfo; * @par Assumptions * None<br> *****************************************************************************/ -N8_Status_t N8_GetSystemParameter(N8_Parameter_t parameter, void *value_p) +N8_Status_t N8_GetSystemParameter(N8_Parameter_t parameter, void *value_p, + size_t value_l) { N8_Status_t ret = N8_STATUS_OK; @@ -156,7 +157,7 @@ N8_Status_t N8_GetSystemParameter(N8_Parameter_t parameter, void *value_p) ret = setNumberOfChips(value_p); break; case N8_SWVERSIONTEXT: - ret = setSWversionText(value_p); + ret = setSWversionText(value_p, value_l); break; case N8_INITIALIZE_INFO: ret = setInitInfo(value_p); @@ -685,9 +686,9 @@ static N8_Status_t setNumberOfChips(N8_Buffer_t *value_p) * @par Assumptions * None<br> *****************************************************************************/ -N8_Status_t setSWversionText(N8_Buffer_t *value_p) +N8_Status_t setSWversionText(N8_Buffer_t *value_p, size_t value_l) { - sprintf(value_p, N8_VERSION_STRING); + snprintf(value_p, value_l, N8_VERSION_STRING); return N8_STATUS_OK; } /* setSWversionText */ diff --git a/sys/dev/pci/n8/include_public/n8_pub_service.h b/sys/dev/pci/n8/include_public/n8_pub_service.h index 3dfde54e09c..4519e3dd677 100644 --- a/sys/dev/pci/n8/include_public/n8_pub_service.h +++ b/sys/dev/pci/n8/include_public/n8_pub_service.h @@ -134,7 +134,7 @@ typedef enum /***************************************************************************** * Function prototypes *****************************************************************************/ -N8_Status_t N8_GetSystemParameter(N8_Parameter_t parameter, void *value_p); +N8_Status_t N8_GetSystemParameter(N8_Parameter_t parameter, void *value_p, size_t value_l); N8_Status_t N8_InitializeAPI(N8_ConfigAPI_t *parameters_p); N8_Status_t N8_EventCheck(N8_Event_t *events_p, const int count, int *ready_p); N8_Status_t N8_EventWait (N8_Event_t *events_p, const int count, int *ready_p); diff --git a/sys/dev/pci/n8/include_public/n8_pub_sks.h b/sys/dev/pci/n8/include_public/n8_pub_sks.h index 30f3ca5b224..04c5e4b4425 100644 --- a/sys/dev/pci/n8/include_public/n8_pub_sks.h +++ b/sys/dev/pci/n8/include_public/n8_pub_sks.h @@ -76,7 +76,7 @@ N8_Status_t N8_SKSGetKeyHandle(const N8_Buffer_t* keyEntryName, N8_SKSKeyHandle_t* keyHandle_p); N8_Status_t N8_SKSDisplay(N8_SKSKeyHandle_t* keyHandle, - char string[1024]); + char *string, size_t stringlength); #ifdef __cplusplus } diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c index eadece49f0a..d16440c96a4 100644 --- a/sys/dev/raidframe/rf_disks.c +++ b/sys/dev/raidframe/rf_disks.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_disks.c,v 1.84 2013/09/15 12:44:03 martin Exp $ */ +/* $NetBSD: rf_disks.c,v 1.85 2014/03/25 16:19:14 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -60,7 +60,7 @@ ***************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.84 2013/09/15 12:44:03 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.85 2014/03/25 16:19:14 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -594,7 +594,8 @@ rf_ConfigureDisk(RF_Raid_t *raidPtr, char *bf, RF_RaidDisk_t *diskPtr, if (!strcmp("absent", diskPtr->devname)) { printf("Ignoring missing component at column %d\n", col); - sprintf(diskPtr->devname, "component%d", col); + snprintf(diskPtr->devname, sizeof(diskPtr->devname), + "component%d", col); diskPtr->status = rf_ds_failed; return (0); } diff --git a/sys/dev/raidframe/rf_general.h b/sys/dev/raidframe/rf_general.h index bc788b33153..baf9437d06f 100644 --- a/sys/dev/raidframe/rf_general.h +++ b/sys/dev/raidframe/rf_general.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_general.h,v 1.20 2013/09/15 12:06:50 martin Exp $ */ +/* $NetBSD: rf_general.h,v 1.21 2014/03/25 16:19:14 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -41,7 +41,7 @@ /* error reporting and handling */ -#include <sys/systm.h> /* printf, sprintf, and friends */ +#include <sys/systm.h> /* printf, snprintf, and friends */ #define RF_ERRORMSG(s) printf((s)) #define RF_ERRORMSG1(s,a) printf((s),(a)) |
