summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-03-23 12:05:44 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-03-23 12:05:44 +0000
commit6dd17c073175c04117dafb70c410dc6ccc047e2d (patch)
treec0b58649f5669a5e8a8b7d317f65031d39a9ee50
parent42eaca3a0cebd3e0176b8a581c553ebf245251e4 (diff)
Do not abort walking the tree if a node's contents is too large; allows
eeprom -p to be used on more macppc models. ok fgsch@
-rw-r--r--usr.sbin/eeprom/optree.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/eeprom/optree.c b/usr.sbin/eeprom/optree.c
index 58c4800c54f..4004978c1ea 100644
--- a/usr.sbin/eeprom/optree.c
+++ b/usr.sbin/eeprom/optree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: optree.c,v 1.4 2008/02/22 20:23:19 kettenis Exp $ */
+/* $OpenBSD: optree.c,v 1.5 2008/03/23 12:05:43 miod Exp $ */
/*
* Copyright (c) 2007 Federico G. Schwindt <fgsch@openbsd.org>
@@ -28,6 +28,7 @@
#include <sys/ioctl.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
@@ -106,7 +107,8 @@ op_print(struct opiocdesc *opio, int depth)
printf("'%s'", &opio->op_buf[i]);
}
}
- }
+ } else if(opio->op_buflen < 0)
+ printf("too large");
printf("\n");
}
@@ -150,8 +152,12 @@ op_nodes(int fd, int node, int depth)
opio.op_buflen = sizeof(op_buf);
/* And its value. */
- if (ioctl(fd, OPIOCGET, &opio) < 0)
- err(1, "OPIOCGET");
+ if (ioctl(fd, OPIOCGET, &opio) < 0) {
+ if (errno != ENOMEM)
+ err(1, "OPIOCGET");
+
+ opio.op_buflen = -1; /* for op_print */
+ }
op_print(&opio, depth + 1);
}