diff options
author | Sven Schnelle <svens@stackframe.org> | 2012-06-20 10:01:47 +0200 |
---|---|---|
committer | Sven Schnelle <svens@stackframe.org> | 2012-06-20 11:07:51 +0200 |
commit | 4fbcaecf9a457d80eaf131a858617756c4f62376 (patch) | |
tree | ddfa2e967939368d8831c7c850bde45c37131377 /util/mptable | |
parent | b00c9a22577876724123468b9668d50d60bfff03 (diff) | |
download | coreboot-4fbcaecf9a457d80eaf131a858617756c4f62376.tar.xz |
mptable: Fix BUS type determination
Change-Id: I7268b35671f6629601fa3b2a589054b8c5da5d78
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-on: http://review.coreboot.org/1112
Tested-by: build bot (Jenkins)
Diffstat (limited to 'util/mptable')
-rw-r--r-- | util/mptable/mptable.c | 19 |
1 files changed, 17 insertions, 2 deletions
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 <unistd.h> #include <stdint.h> +#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); |