[coreboot] [commit] r5015 - trunk/util/nvramtool
svn at coreboot.org
svn at coreboot.org
Sat Jan 16 15:57:32 CET 2010
Author: stepan
Date: 2010-01-16 15:57:32 +0100 (Sat, 16 Jan 2010)
New Revision: 5015
Modified:
trunk/util/nvramtool/nvramtool.c
Log:
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 at coresystems.de>
Acked-by: Patrick Georgi <patrick.georgi at coresystems.de>
Modified: trunk/util/nvramtool/nvramtool.c
===================================================================
--- trunk/util/nvramtool/nvramtool.c 2010-01-16 13:49:03 UTC (rev 5014)
+++ trunk/util/nvramtool/nvramtool.c 2010-01-16 14:57:32 UTC (rev 5015)
@@ -672,6 +672,7 @@
{
const cmos_enum_t *p;
unsigned long long value;
+ char *w;
/* sanity check CMOS entry */
switch (prepare_cmos_read(e)) {
@@ -741,12 +742,27 @@
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);
break;
More information about the coreboot
mailing list