cbfs: Fix overwalk on file scan
A bootblock overwalk was occuring when deriving the actual length, the bootblock size was not taken into account and bootblock size was not aligned. Resolved merge conflict. BUG=chrome-os-partner:21841 BRANCH=peppy TEST=execute on DUT: "localhost ~ # sudo suspend_stress_test", verfify there is no CBFS: ERROR Change-Id: I7eb42f8deaaf223dcf07b37bb7dde4643acd508f Signed-off-by: Steven Sherk <steven.sherk@se-eng.com> Reviewed-on: https://gerrit.chromium.org/gerrit/65989 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Commit-Queue: Steve Sherk <ssherk70@gmail.com> Tested-by: Steve Sherk <ssherk70@gmail.com>
This commit is contained in:
parent
95b518877e
commit
20b0ba479b
2 changed files with 26 additions and 4 deletions
|
|
@ -119,11 +119,22 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
|
|||
// TODO Add a "size" in CBFS header for a platform independent way to
|
||||
// determine the end of CBFS data.
|
||||
#if defined(CONFIG_LP_ARCH_X86) && CONFIG_LP_ARCH_X86
|
||||
romsize -= htonl(header->bootblocksize);
|
||||
#endif
|
||||
DEBUG("CBFS location: 0x%x~0x%x, align: %d\n", offset, romsize, align);
|
||||
// resolve actual length of ROM used for CBFS components
|
||||
// the bootblock size was not taken into account
|
||||
romsize -= ntohl(header->bootblocksize);
|
||||
|
||||
// fine tune the length to handle alignment positioning.
|
||||
// using (bootblock size) % align, to derive the
|
||||
// number of bytes the bootblock is off from the alignment size.
|
||||
if ((ntohl(header->bootblocksize) % align))
|
||||
romsize -= (align - (ntohl(header->bootblocksize) % align));
|
||||
else
|
||||
romsize -= 1;
|
||||
#endif
|
||||
|
||||
DEBUG("CBFS location: 0x%x~0x%x, align: %d\n", offset, romsize, align);
|
||||
DEBUG("Looking for '%s' starting from 0x%x.\n", name, offset);
|
||||
|
||||
media->open(media);
|
||||
while (offset < romsize &&
|
||||
media->read(media, &file, offset, sizeof(file)) == sizeof(file)) {
|
||||
|
|
|
|||
|
|
@ -119,11 +119,22 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
|
|||
// TODO Add a "size" in CBFS header for a platform independent way to
|
||||
// determine the end of CBFS data.
|
||||
#if defined(CONFIG_ARCH_X86) && CONFIG_ARCH_X86
|
||||
romsize -= htonl(header->bootblocksize);
|
||||
#endif
|
||||
DEBUG("CBFS location: 0x%x~0x%x, align: %d\n", offset, romsize, align);
|
||||
// resolve actual length of ROM used for CBFS components
|
||||
// the bootblock size was not taken into account
|
||||
romsize -= ntohl(header->bootblocksize);
|
||||
|
||||
// fine tune the length to handle alignment positioning.
|
||||
// using (bootblock size) % align, to derive the
|
||||
// number of bytes the bootblock is off from the alignment size.
|
||||
if ((ntohl(header->bootblocksize) % align))
|
||||
romsize -= (align - (ntohl(header->bootblocksize) % align));
|
||||
else
|
||||
romsize -= 1;
|
||||
#endif
|
||||
|
||||
DEBUG("CBFS location: 0x%x~0x%x, align: %d\n", offset, romsize, align);
|
||||
DEBUG("Looking for '%s' starting from 0x%x.\n", name, offset);
|
||||
|
||||
media->open(media);
|
||||
while (offset < romsize &&
|
||||
media->read(media, &file, offset, sizeof(file)) == sizeof(file)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue