diff options
author | Sol Boucher <solb@chromium.org> | 2015-05-05 15:35:18 -0700 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-05-08 20:22:44 +0200 |
commit | 297c88c35748ecd1f82fc96b71e10b118c587c71 (patch) | |
tree | b53980d34040042726fa3243a363240a14085d82 | |
parent | c5269007c9bdeb3acae945ed39001983367d5c51 (diff) |
cbfstool: Fix cbfs_copy_instance()'s master header endianness
The function hadn't been updated to account for the fact that we now
copy an endianness-corrected CBFS master header into a separate buffer
from the CBFS data: it still performed pointer arithmetic accross the
two buffers and wrote the copied buffer into the image without
restoring the original endianness.
Change-Id: Ieb2a001f253494cf3a90d7e19cd260791200c4d3
Signed-off-by: Sol Boucher <solb@chromium.org>
Reviewed-on: http://review.coreboot.org/10122
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
-rw-r--r-- | util/cbfstool/cbfs_image.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 8e0e9a48ab..457a87340c 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -336,17 +336,13 @@ int cbfs_copy_instance(struct cbfs_image *image, size_t copy_offset, size_t align, entry_offset; ssize_t last_entry_size; - size_t header_offset, header_end; size_t cbfs_offset, cbfs_end; size_t copy_end = copy_offset + copy_size; - align = htonl(image->header->align); + align = image->header->align; - header_offset = (char *)image->header - image->buffer.data; - header_end = header_offset + sizeof(image->header); - - cbfs_offset = htonl(image->header->offset); - cbfs_end = htonl(image->header->romsize); + cbfs_offset = image->header->offset; + cbfs_end = image->header->romsize; if (copy_end > image->buffer.size) { ERROR("Copy offset out of range: [%zx:%zx)\n", @@ -354,12 +350,7 @@ int cbfs_copy_instance(struct cbfs_image *image, size_t copy_offset, return 1; } - /* Range check requested copy region with header and source cbfs. */ - if ((copy_offset >= header_offset && copy_offset < header_end) || - (copy_end >= header_offset && copy_end <= header_end)) { - ERROR("New image would overlap old header.\n"); - } - + /* Range check requested copy region with source cbfs. */ if ((copy_offset >= cbfs_offset && copy_offset < cbfs_end) || (copy_end >= cbfs_offset && copy_end <= cbfs_end)) { ERROR("New image would overlap old one.\n"); @@ -368,7 +359,7 @@ int cbfs_copy_instance(struct cbfs_image *image, size_t copy_offset, /* This will work, let's create a copy. */ copy_header = (struct cbfs_header *)(image->buffer.data + copy_offset); - *copy_header = *image->header; + cbfs_put_header(copy_header, image->header); copy_header->bootblocksize = 0; /* Romsize is a misnomer. It's the absolute limit of cbfs content.*/ |