diff options
author | Nico Huber <nico.h@gmx.de> | 2018-12-22 00:53:14 +0100 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2019-04-02 16:42:53 +0000 |
commit | 3d7b1e3b5c04304d3680bd950e7672f6336b01d6 (patch) | |
tree | f316ba1bd2474850ff3267ff1acbbb2b9c7336cd /flashrom.c | |
parent | 0cacb11c6252b6e1f4f0a2a33b47717ff22995d9 (diff) | |
download | flashrom-3d7b1e3b5c04304d3680bd950e7672f6336b01d6.tar.gz flashrom-3d7b1e3b5c04304d3680bd950e7672f6336b01d6.tar.bz2 flashrom-3d7b1e3b5c04304d3680bd950e7672f6336b01d6.zip |
Fix verification with sparse layouts
The full verification step was not accounting for sparse layouts.
Instead of the old contents, combine_image_by_layout() implicitly
assumed the new contents for unspecified regions.
Change-Id: I44e0cea621f2a3d4dc70fa7e93c52ed95e54014a
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/30370
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Diffstat (limited to 'flashrom.c')
-rw-r--r-- | flashrom.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -2430,17 +2430,23 @@ static void combine_image_by_layout(const struct flashctx *const flashctx, uint8_t *const newcontents, const uint8_t *const oldcontents) { const struct flashrom_layout *const layout = get_layout(flashctx); + const struct romentry *included; + chipoff_t start = 0; - size_t i; - for (i = 0; i < layout->num_entries; ++i) { - if (layout->entries[i].included) - continue; - - const chipoff_t region_start = layout->entries[i].start; - const chipsize_t region_len = layout->entries[i].end - layout->entries[i].start + 1; - - memcpy(newcontents + region_start, oldcontents + region_start, region_len); + while ((included = layout_next_included_region(layout, start))) { + if (included->start > start) { + /* copy everything up to the start of this included region */ + memcpy(newcontents + start, oldcontents + start, included->start - start); + } + /* skip this included region */ + start = included->end + 1; + if (start == 0) + return; } + + /* copy the rest of the chip */ + const chipsize_t copy_len = flashctx->chip->total_size * 1024 - start; + memcpy(newcontents + start, oldcontents + start, copy_len); } /** |