diff options
| author | itojun <itojun@NetBSD.org> | 2004-04-22 00:17:10 +0000 |
|---|---|---|
| committer | itojun <itojun@NetBSD.org> | 2004-04-22 00:17:10 +0000 |
| commit | aca4c091d32e5d41fde26cf072df6355ec7fa79b (patch) | |
| tree | 498f57df69e0a3d0b702d3aa166ed352fe32e53f /sys/dev/ofw | |
| parent | fd2a977729985cfb18c9fefeca871d3649724943 (diff) | |
sprintf -> snprintf
Diffstat (limited to 'sys/dev/ofw')
| -rw-r--r-- | sys/dev/ofw/ofbus.c | 12 | ||||
| -rw-r--r-- | sys/dev/ofw/ofw_subr.c | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/sys/dev/ofw/ofbus.c b/sys/dev/ofw/ofbus.c index e2b27fbaf5a..ca9f41c99a0 100644 --- a/sys/dev/ofw/ofbus.c +++ b/sys/dev/ofw/ofbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofbus.c,v 1.17 2003/01/01 00:10:22 thorpej Exp $ */ +/* $NetBSD: ofbus.c,v 1.18 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ofbus.c,v 1.17 2003/01/01 00:10:22 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofbus.c,v 1.18 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -110,10 +110,12 @@ ofbus_attach(parent, dev, aux) for (oba2.oba_unit = 0; oba2.oba_unit < units; oba2.oba_unit++) { if (units > 1) { - sprintf(oba2.oba_ofname, "%s@%d", name, - oba2.oba_unit); + snprintf(oba2.oba_ofname, + sizeof(oba2.oba_ofname), "%s@%d", name, + oba2.oba_unit); } else { - strcpy(oba2.oba_ofname, name); + strlcpy(oba2.oba_ofname, name, + sizeof(oba2.oba_ofname)); } config_found(dev, &oba2, ofbus_print); } diff --git a/sys/dev/ofw/ofw_subr.c b/sys/dev/ofw/ofw_subr.c index b93d6b1e0dc..3aed1ed2ec5 100644 --- a/sys/dev/ofw/ofw_subr.c +++ b/sys/dev/ofw/ofw_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofw_subr.c,v 1.8 2003/01/06 13:26:27 wiz Exp $ */ +/* $NetBSD: ofw_subr.c,v 1.9 2004/04/22 00:17:12 itojun Exp $ */ /* * Copyright 1998 @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.8 2003/01/06 13:26:27 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.9 2004/04/22 00:17:12 itojun Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -190,11 +190,10 @@ of_packagename(phandle, buf, bufsize) /* check that we could get the name, and that it's not too long. */ if (l < 0 || (l == OFW_PATH_BUF_SIZE && pbuf[OFW_PATH_BUF_SIZE - 1] != '\0')) { - /* XXX should use snprintf! */ if (bufsize >= 25) - sprintf(buf, "??? (phandle 0x%x)", phandle); + snprintf(buf, bufsize, "??? (phandle 0x%x)", phandle); else if (bufsize >= 4) - strcpy(buf, "???"); + strlcpy(buf, "???", bufsize); else panic("of_packagename: bufsize = %d is silly", bufsize); @@ -202,9 +201,8 @@ of_packagename(phandle, buf, bufsize) } else { pbuf[l] = '\0'; lastslash = strrchr(pbuf, '/'); - strncpy(buf, (lastslash == NULL) ? pbuf : (lastslash + 1), + strlcpy(buf, (lastslash == NULL) ? pbuf : (lastslash + 1), bufsize); - buf[bufsize - 1] = '\0'; /* in case it's fills the buffer. */ rv = 0; } |
