summaryrefslogtreecommitdiffstats
path: root/util/cbfstool/cbfs_image.c
diff options
context:
space:
mode:
authorJakub Czapiga <jacz@semihalf.com>2022-08-01 16:01:28 +0200
committerJulius Werner <jwerner@chromium.org>2022-08-03 23:24:49 +0000
commitaa41563483ca5a88afc22985a89df05166302cd2 (patch)
tree8d00738e58b0d1421da53baa66ea3a69ce662f8e /util/cbfstool/cbfs_image.c
parent77b2d45c9e4374320e802749e144bf40cb4a3f87 (diff)
downloadcoreboot-aa41563483ca5a88afc22985a89df05166302cd2.tar.gz
coreboot-aa41563483ca5a88afc22985a89df05166302cd2.tar.bz2
coreboot-aa41563483ca5a88afc22985a89df05166302cd2.zip
util/cbfstool: Fix truncate command error handling and cbfs_image_from_buffer()
Check return value of cbfs_truncate_space() in cbfs_truncate(). Remove return from cbfs_image_from_buffer() to inform about invalid image region when incorrect offset header was provided. Also change header offset provided to mentioned function in cbfs_expand_to_region() and cbfs_truncate_space() from zero to HEADER_OFFSET_UNKNOWN, as they do not support images with cbfs master header. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ib009212692fb3594a826436df765860f54837154 Reviewed-on: https://review.coreboot.org/c/coreboot/+/66334 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'util/cbfstool/cbfs_image.c')
-rw-r--r--util/cbfstool/cbfs_image.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 5f30877df22b..97ad9955455f 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -346,9 +346,8 @@ int cbfs_image_from_buffer(struct cbfs_image *out, struct buffer *in,
out->has_header = true;
cbfs_fix_legacy_size(out, header_loc);
return 0;
- } else if (offset != ~0u) {
+ } else if (offset != HEADER_OFFSET_UNKNOWN) {
ERROR("The -H switch is only valid on legacy images having CBFS master headers.\n");
- return 1;
}
ERROR("Selected image region is not a valid CBFS.\n");
return 1;
@@ -415,7 +414,7 @@ int cbfs_expand_to_region(struct buffer *region)
struct cbfs_image image;
memset(&image, 0, sizeof(image));
- if (cbfs_image_from_buffer(&image, region, 0)) {
+ if (cbfs_image_from_buffer(&image, region, HEADER_OFFSET_UNKNOWN)) {
ERROR("reading CBFS failed!\n");
return 1;
}
@@ -454,7 +453,7 @@ int cbfs_truncate_space(struct buffer *region, uint32_t *size)
struct cbfs_image image;
memset(&image, 0, sizeof(image));
- if (cbfs_image_from_buffer(&image, region, 0)) {
+ if (cbfs_image_from_buffer(&image, region, HEADER_OFFSET_UNKNOWN)) {
ERROR("reading CBFS failed!\n");
return 1;
}