Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/30370
Change subject: Fix verification with sparse layouts ......................................................................
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 --- M flashrom.c 1 file changed, 11 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/70/30370/1
diff --git a/flashrom.c b/flashrom.c index 59a7531..4e10629 100644 --- a/flashrom.c +++ b/flashrom.c @@ -2355,17 +2355,24 @@ uint8_t *const newcontents, const uint8_t *const oldcontents) { const struct flashrom_layout *const layout = get_layout(flashctx); + chipoff_t next = 0;
size_t i; for (i = 0; i < layout->num_entries; ++i) { - if (layout->entries[i].included) + 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; + /* copy everything up to the start of this included region */ + const chipsize_t copy_len = layout->entries[i].start - next; + memcpy(newcontents + next, oldcontents + next, copy_len);
- memcpy(newcontents + region_start, oldcontents + region_start, region_len); + /* skip this included region */ + next = layout->entries[i].end + 1; } + + /* copy the rest of the chip */ + const chipsize_t copy_len = flashctx->chip->total_size * 1024 - next; + memcpy(newcontents + next, oldcontents + next, copy_len); }
/**