Page MenuHomeFreeBSD

D26669.diff
No OneTemporary

D26669.diff

Index: head/sys/dev/ofw/openfirmio.h
===================================================================
--- head/sys/dev/ofw/openfirmio.h
+++ head/sys/dev/ofw/openfirmio.h
@@ -76,4 +76,18 @@
/* Maximum accepted value length (maximum of nvramrc property). */
#define OFIOCMAXVALUE 8192
+/*
+ * While IEEE 1275-1994 states in 3.2.2.1.1 that property names are 1-31
+ * printable characters, in practice, this limit has been ignored.
+ * Noncompliant properties have been codified in standards such as LoPAPR.
+ *
+ * This is a suggested buffer length that should be large enough to hold
+ * any property name currently seen in device trees, without being overly
+ * wasteful of memory.
+ *
+ * If a future version of the Devicetree specification updates the property
+ * names length requirement, this value will be updated to match.
+ */
+#define OFIOCSUGGPROPNAMELEN 64
+
#endif /* _DEV_OFW_OPENFIRMIO_H_ */
Index: head/sys/dev/ofw/openfirmio.c
===================================================================
--- head/sys/dev/ofw/openfirmio.c
+++ head/sys/dev/ofw/openfirmio.c
@@ -115,7 +115,7 @@
phandle_t node;
int len, ok, error;
char *name, *value;
- char newname[32];
+ char newname[OFIOCSUGGPROPNAMELEN];
if ((flags & FREAD) == 0)
return (EBADF);
@@ -222,8 +222,19 @@
break;
}
len = strlen(newname) + 1;
- if (len > of->of_buflen)
+ if (len > of->of_buflen) {
+ /*
+ * Passed buffer was insufficient.
+ *
+ * Instead of returning an error here, truncate the
+ * property name to fit the buffer.
+ *
+ * This allows us to retain compatibility with old
+ * tools which always pass a 32 character buffer.
+ */
len = of->of_buflen;
+ newname[len - 1] = '\0';
+ }
else
of->of_buflen = len;
error = copyout(newname, of->of_buf, len);
Index: head/usr.sbin/ofwdump/ofwdump.c
===================================================================
--- head/usr.sbin/ofwdump/ofwdump.c
+++ head/usr.sbin/ofwdump/ofwdump.c
@@ -144,7 +144,7 @@
ofw_dump_properties(int fd, phandle_t n, int level, int raw, int str)
{
int nlen;
- char prop[32];
+ char prop[OFIOCSUGGPROPNAMELEN];
for (nlen = ofw_firstprop(fd, n, prop, sizeof(prop)); nlen != 0;
nlen = ofw_nextprop(fd, n, prop, prop, sizeof(prop)))

File Metadata

Mime Type
text/plain
Expires
Wed, Feb 5, 12:04 PM (21 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16473902
Default Alt Text
D26669.diff (2 KB)

Event Timeline