From 016b5abc837cc8ceaa939d1e881cb07a3185cbff Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Mon, 14 Feb 2022 17:07:39 -0800 Subject: libflashrom/fmap: Don't use off_t for flash offsets off_t is a special POSIX type that is used to represent file offsets in certain APIs (e.g. lseek(), mmap()), and should not be reused to represent anything else (such as flash offsets). In particular, the width of the type may change based on the definition of the _FILE_OFFSET_BITS macro. Using such a type at the libflashrom interface is particularly dangerous, because if a program is built with a different _FILE_OFFSET_BITS value than libflashrom, the resulting ABI corruption will cause very very nasty and confusing bugs. This patch replaces all instances of off_t that are not related to file offsets with (s)size_t. BUG=b:219811851 TEST=`elogtool list` on cherry. Signed-off-by: Julius Werner Change-Id: I68a386973f79ea634f63dfcd7d95a63400e1fdee Reviewed-on: https://review.coreboot.org/c/flashrom/+/61943 Reviewed-by: Nico Huber Reviewed-by: Angel Pons Reviewed-by: Edward O'Callaghan Reviewed-by: Nikolai Artemiev Tested-by: build bot (Jenkins) --- libflashrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libflashrom.c') diff --git a/libflashrom.c b/libflashrom.c index fb7093450..d66c29596 100644 --- a/libflashrom.c +++ b/libflashrom.c @@ -534,7 +534,7 @@ static int flashrom_layout_parse_fmap(struct flashrom_layout **layout, * 1 on any other error. */ int flashrom_layout_read_fmap_from_rom(struct flashrom_layout **const layout, - struct flashctx *const flashctx, off_t offset, size_t len) + struct flashctx *const flashctx, size_t offset, size_t len) { #ifndef __FLASHROM_LITTLE_ENDIAN__ return 3; -- cgit v1.2.3