summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2010-01-16 14:57:32 +0000
committerStefan Reinauer <stepan@openbios.org>2010-01-16 14:57:32 +0000
commit42944c3989f27b14a66fa7c75a47c820c8d92119 (patch)
tree79025ecbbc57b3a3db1f6ea69fa43e49cab38d00 /util
parent12ee934cb398f28a29ceef455c98ff3fa2ad956f (diff)
downloadcoreboot-42944c3989f27b14a66fa7c75a47c820c8d92119.tar.xz
nvramtool: Consider a string with non-printable characters a "bad value".
Otherwise nvramtool -a with random cmos contents can mess up your terminal. Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Patrick Georgi <patrick.georgi@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5015 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rw-r--r--util/nvramtool/nvramtool.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/util/nvramtool/nvramtool.c b/util/nvramtool/nvramtool.c
index f26ca97e8a..89ddf31d71 100644
--- a/util/nvramtool/nvramtool.c
+++ b/util/nvramtool/nvramtool.c
@@ -672,6 +672,7 @@ static int list_cmos_entry(const cmos_entry_t * e, int show_name)
{
const cmos_enum_t *p;
unsigned long long value;
+ char *w;
/* sanity check CMOS entry */
switch (prepare_cmos_read(e)) {
@@ -741,11 +742,26 @@ static int list_cmos_entry(const cmos_entry_t * e, int show_name)
break;
case CMOS_ENTRY_STRING:
- if (show_name)
- printf("%s = %s\n", e->name,
- (char *)(unsigned long)value);
- else
- printf("%s\n", (char *)(unsigned long)value);
+ w = (char *)(unsigned long)value;
+ while (*w) {
+ if(!isprint(*w)) {
+ if (show_name)
+ printf("# Bad value -> %s\n", e->name);
+ else
+ printf("Bad value\n");
+ break;
+ }
+ w++;
+ }
+
+ if (!*w) {
+
+ if (show_name)
+ printf("%s = %s\n", e->name,
+ (char *)(unsigned long)value);
+ else
+ printf("%s\n", (char *)(unsigned long)value);
+ }
free((void *)(unsigned long)value);