From 7bcacb1bdb72f60f37a67883f871bbef9ec8c943 Mon Sep 17 00:00:00 2001 From: Stefan Tauner Date: Thu, 26 May 2011 01:35:19 +0000 Subject: Eliminate magic numbers indicating maximum column sizes in print.c Without this the magic numbers need to be kept in sync with the maximum length of the strings printed in the corresponding column. if not, an overflow and a nasty ' '-storm occur on executing flashrom -L. Corresponding to flashrom svn r1318. Signed-off-by: Stefan Tauner Acked-by: Carl-Daniel Hailfinger --- flashrom.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'flashrom.c') diff --git a/flashrom.c b/flashrom.c index 46c9ecd3..14d52638 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1709,9 +1709,37 @@ int selfcheck(void) msg_gerr("Programmer table miscompilation!\n"); ret = 1; } + /* It would be favorable if we could also check for correct terminaion + * of the follwing arrays, but we don't know their size in here... + * For 'flashchips' we check the first element to be non-null. In the + * other cases there exist use cases where the first element can be + * null. */ + if (flashchips == NULL || flashchips[0].vendor == NULL) { + msg_gerr("Flashchips table miscompilation!\n"); + ret = 1; + } for (flash = flashchips; flash && flash->name; flash++) if (selfcheck_eraseblocks(flash)) ret = 1; + +#if CONFIG_INTERNAL == 1 + if (chipset_enables == NULL) { + msg_gerr("Chipset enables table does not exist!\n"); + ret = 1; + } + if (board_pciid_enables == NULL) { + msg_gerr("Board enables table does not exist!\n"); + ret = 1; + } + if (boards_known == NULL) { + msg_gerr("Known boards table does not exist!\n"); + ret = 1; + } + if (laptops_known == NULL) { + msg_gerr("Known laptops table does not exist!\n"); + ret = 1; + } +#endif // CONFIG_INTERNAL == 1 return ret; } -- cgit v1.2.3