From 4fbcaecf9a457d80eaf131a858617756c4f62376 Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Wed, 20 Jun 2012 10:01:47 +0200 Subject: mptable: Fix BUS type determination Change-Id: I7268b35671f6629601fa3b2a589054b8c5da5d78 Signed-off-by: Sven Schnelle Reviewed-on: http://review.coreboot.org/1112 Tested-by: build bot (Jenkins) --- util/mptable/mptable.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/mptable/mptable.c b/util/mptable/mptable.c index 80d47421cf..1aabe1782f 100644 --- a/util/mptable/mptable.c +++ b/util/mptable/mptable.c @@ -50,6 +50,7 @@ #include #include +#define ARRAY_SIZE(_x) (sizeof(_x) / sizeof(_x[0])) #define SEP_LINE \ "\n-------------------------------------------------------------------------------\n" @@ -982,7 +983,7 @@ static void busEntry(void) { char name[8]; BusEntry entry; - + int i; /* read it into local memory */ readEntry(&entry, sizeof(entry)); @@ -997,7 +998,21 @@ static void busEntry(void) } memset(name, '\0', sizeof(name)); - strncpy(name, (char *)entry.busType, 6); + for(i = 0; i < 6; i++) { + switch(entry.busType[i]) { + case ' ': + case '\0': + break; + default: + name[i] = entry.busType[i]; + break; + } + } + + if (entry.busID > ARRAY_SIZE(busses)) { + fprintf(stderr, "busses array to small!\n"); + exit(1); + } busses[entry.busID] = lookupBusType(name); printf("\tsmp_write_bus(mc, %d, \"", entry.busID); -- cgit v1.2.3