diff options
author | Bill Richardson <wfrichar@chromium.org> | 2014-08-27 15:50:25 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-03 22:49:52 +0000 |
commit | cf6e78dbd54684ebba0c3bfc2524426f61193416 (patch) | |
tree | b8bab8d134c71546773befeb7fb4077341718c91 /futility/cmd_gbb_utility.c | |
parent | 487a54bcbe7b6dac1a856b0991e6d13c34a1c423 (diff) | |
download | vboot-cf6e78dbd54684ebba0c3bfc2524426f61193416.tar.gz |
futility: the show command can traverse all file types
It doesn't yet handle block devices, but it can display normal files
containing a entire BIOS image, a GBB, a VBLOCK, a .vbpubk, a .vblock,
and a firmware preamble (VbFirmwarePreambleHeader).
The command-line options are not well-documented.
BUG=chromium:224734
BRANCH=ToT
TEST=make runtests
Change-Id: I181f6331ae23599302bbaee3f270e8af9586cf06
Reviewed-on: https://chromium-review.googlesource.com/216032
Commit-Queue: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'futility/cmd_gbb_utility.c')
-rw-r--r-- | futility/cmd_gbb_utility.c | 44 |
1 files changed, 1 insertions, 43 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c index 9810058d..428f05b2 100644 --- a/futility/cmd_gbb_utility.c +++ b/futility/cmd_gbb_utility.c @@ -74,48 +74,6 @@ static char *short_opts = ":gsc:o:k:b:R:r:h:i:L:f:"; static int errorcnt; -static int ValidGBB(GoogleBinaryBlockHeader * gbb, size_t maxlen) -{ - uint32_t i; - char *s; - - if (gbb->major_version != GBB_MAJOR_VER) - goto bad; - if (gbb->header_size != GBB_HEADER_SIZE || gbb->header_size > maxlen) - goto bad; - if (gbb->hwid_offset < GBB_HEADER_SIZE) - goto bad; - if (gbb->hwid_offset + gbb->hwid_size > maxlen) - goto bad; - if (gbb->hwid_size) { - /* Make sure the HWID is null-terminated (ASCII, not unicode) */ - s = (char *)((char *)gbb + gbb->hwid_offset); - for (i = 0; i < gbb->hwid_size; i++) - if (*s++ == '\0') - break; - if (i >= gbb->hwid_size) - goto bad; - } - if (gbb->rootkey_offset < GBB_HEADER_SIZE) - goto bad; - if (gbb->rootkey_offset + gbb->rootkey_size > maxlen) - goto bad; - if (gbb->bmpfv_offset < GBB_HEADER_SIZE) - goto bad; - if (gbb->bmpfv_offset + gbb->bmpfv_size > maxlen) - goto bad; - if (gbb->recovery_key_offset < GBB_HEADER_SIZE) - goto bad; - if (gbb->recovery_key_offset + gbb->recovery_key_size > maxlen) - goto bad; - - return 1; - -bad: - errorcnt++; - return 0; -} - #define GBB_SEARCH_STRIDE 4 GoogleBinaryBlockHeader *FindGbbHeader(uint8_t * ptr, size_t size) { @@ -129,7 +87,7 @@ GoogleBinaryBlockHeader *FindGbbHeader(uint8_t * ptr, size_t size) /* Found something. See if it's any good. */ tmp = (GoogleBinaryBlockHeader *) (ptr + i); - if (ValidGBB(tmp, size - i)) + if (futil_valid_gbb_header(tmp, size - i, NULL)) if (!count++) gbb_header = tmp; } |