summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorpk <pk@NetBSD.org>2004-03-17 15:22:57 +0000
committerpk <pk@NetBSD.org>2004-03-17 15:22:57 +0000
commitfcac5c14aa06a92abf76d76e7de15751c80e266c (patch)
tree18fa320cb950e6e260e18e899ad70bedc9aea26c /sys
parent370bb883e52448d4833b95aa6c5581c489d95d67 (diff)
Pass the buffer size to PROM_getpropstringA(), as in sparc.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc64/dev/sbus.c12
-rw-r--r--sys/arch/sparc64/include/autoconf.h4
-rw-r--r--sys/arch/sparc64/sparc64/autoconf.c15
3 files changed, 17 insertions, 14 deletions
diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c
index e0fbef8a69d..d8b74d0273c 100644
--- a/sys/arch/sparc64/dev/sbus.c
+++ b/sys/arch/sparc64/dev/sbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sbus.c,v 1.65 2003/11/09 14:28:56 martin Exp $ */
+/* $NetBSD: sbus.c,v 1.66 2004/03/17 15:22:57 pk Exp $ */
/*
* Copyright (c) 1999-2002 Eduardo Horvath
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.65 2003/11/09 14:28:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.66 2004/03/17 15:22:57 pk Exp $");
#include "opt_ddb.h"
@@ -350,7 +350,7 @@ sbus_setup_attach_args(sc, bustag, dmatag, node, sa)
char buf[32];
if (error != ENOENT ||
!node_has_property(node, "device_type") ||
- strcmp(PROM_getpropstringA(node, "device_type", buf),
+ strcmp(PROM_getpropstringA(node, "device_type", buf, sizeof buf),
"hierarchical") != 0)
return (error);
}
@@ -567,9 +567,9 @@ sbus_get_intr(sc, node, ipp, np, slot)
* somehow. Luckily, the interrupt vector has lots of free
* space and we can easily stuff the IPL in there for a while.
*/
- PROM_getpropstringA(node, "device_type", buf);
- if (!buf[0])
- PROM_getpropstringA(node, "name", buf);
+ PROM_getpropstringA(node, "device_type", buf, sizeof buf);
+ if (buf[0] == '\0')
+ PROM_getpropstringA(node, "name", buf, sizeof buf);
for (i = 0; intrmap[i].in_class; i++)
if (strcmp(intrmap[i].in_class, buf) == 0) {
diff --git a/sys/arch/sparc64/include/autoconf.h b/sys/arch/sparc64/include/autoconf.h
index c7b1620905a..9dda3934613 100644
--- a/sys/arch/sparc64/include/autoconf.h
+++ b/sys/arch/sparc64/include/autoconf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.h,v 1.17 2004/03/16 23:05:46 pk Exp $ */
+/* $NetBSD: autoconf.h,v 1.18 2004/03/17 15:22:57 pk Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -136,7 +136,7 @@ int PROM_getpropint __P((int node, char *name, int deflt));
extern int optionsnode;
/* new interfaces: */
-char *PROM_getpropstringA __P((int, char *, char *));
+char *PROM_getpropstringA __P((int, char *, char *, size_t));
struct idprom *prom_getidprom(void);
void prom_getether(int, u_char *);
diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c
index a4704307f5d..25a684b6dc6 100644
--- a/sys/arch/sparc64/sparc64/autoconf.c
+++ b/sys/arch/sparc64/sparc64/autoconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.91 2004/03/17 14:35:53 pk Exp $ */
+/* $NetBSD: autoconf.c,v 1.92 2004/03/17 15:22:57 pk Exp $ */
/*
* Copyright (c) 1996
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.91 2004/03/17 14:35:53 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.92 2004/03/17 15:22:57 pk Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -778,7 +778,6 @@ PROM_getprop(node, name, size, nitem, bufp)
void *buf;
long len;
- *nitem = 0;
len = PROM_getproplen(node, name);
if (len <= 0)
return (ENOENT);
@@ -792,6 +791,9 @@ PROM_getprop(node, name, size, nitem, bufp)
buf = malloc(len, M_DEVBUF, M_NOWAIT);
if (buf == NULL)
return (ENOMEM);
+ } else {
+ if (size * (*nitem) < len)
+ return (ENOMEM);
}
OF_getprop(node, name, buf, len);
@@ -824,17 +826,18 @@ PROM_getpropstring(node, name)
{
static char stringbuf[32];
- return (PROM_getpropstringA(node, name, stringbuf));
+ return (PROM_getpropstringA(node, name, stringbuf, sizeof stringbuf));
}
/* Alternative PROM_getpropstring(), where caller provides the buffer */
char *
-PROM_getpropstringA(node, name, buffer)
+PROM_getpropstringA(node, name, buffer, bufsize)
int node;
char *name;
char *buffer;
+ size_t bufsize;
{
- int blen;
+ int blen = bufsize - 1;
if (PROM_getprop(node, name, 1, &blen, &buffer) != 0)
blen = 0;