mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-26 22:52:34 +02:00
layout.c: Ensure filename is always consistent in layout structure
Ensure construction and extraction filenames are symmetrical consistently within the layout structure. Change-Id: I9a0c3130c0e7d88a8a69fd29362c338e20d2bae8 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/72943 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
parent
6537d40e31
commit
f3c21c6439
19
layout.c
19
layout.c
@ -194,6 +194,15 @@ error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char *sanitise_filename(char *filename)
|
||||
{
|
||||
for (unsigned i = 0; filename[i]; i++) {
|
||||
if (isspace((unsigned char)filename[i]))
|
||||
filename[i] = '_';
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
/* returns 0 to indicate success, 1 to indicate failure */
|
||||
static int include_region(struct flashrom_layout *const l, const char *name,
|
||||
const char *file)
|
||||
@ -202,7 +211,7 @@ static int include_region(struct flashrom_layout *const l, const char *name,
|
||||
if (entry) {
|
||||
entry->included = true;
|
||||
if (file)
|
||||
entry->file = strdup(file);
|
||||
entry->file = sanitise_filename(strdup(file));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -342,18 +351,12 @@ void prepare_layout_for_extraction(struct flashctx *flash)
|
||||
{
|
||||
const struct flashrom_layout *const l = get_layout(flash);
|
||||
struct romentry *entry = NULL;
|
||||
unsigned int i;
|
||||
|
||||
while ((entry = mutable_layout_next(l, entry))) {
|
||||
entry->included = true;
|
||||
|
||||
if (!entry->file)
|
||||
entry->file = strdup(entry->region.name);
|
||||
|
||||
for (i = 0; entry->file[i]; ++i) {
|
||||
if (isspace((unsigned char)entry->file[i]))
|
||||
entry->file[i] = '_';
|
||||
}
|
||||
entry->file = sanitise_filename(strdup(entry->region.name));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user