summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-03 23:12:15 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-03 23:12:15 +0000
commit7b15b020b573cd98da074a72deb2e57b5a8618e3 (patch)
tree2f4b3bf17cf11dca5f2891334d11f489f0fc1d26 /util
parentae080c35e47ed0e9aeaa861e615b1a359f27b7d6 (diff)
util/nvmutil: use off_t for partsize (pread/pwrite)
size_t can truncate on some platforms. it's best to use the proper variable type (a cast is insufficient). Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 204013c8..2dd3028f 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -65,7 +65,7 @@ static void set_err(int);
static uint8_t buf[SIZE_8KB];
static uint16_t macbuf[3];
-static size_t partsize;
+static off_t partsize;
static int flags;
static int rfd;
@@ -250,7 +250,7 @@ read_gbe_part(int p, int invert)
for (retry = 0; retry < (int) MAX_RETRY_READ; retry++) {
rval = pread(fd, buf + (SIZE_4KB * (p ^ invert)),
- SIZE_4KB, p * partsize);
+ SIZE_4KB, ((off_t ) p) * partsize);
if (valid_read(fname, rval,
(ssize_t) SIZE_4KB, retry, "pread")) {
@@ -582,7 +582,7 @@ write_gbe_part(int p)
swap(p); /* swap bytes on big-endian host CPUs */
if (pwrite(fd, buf + (SIZE_4KB * p),
- SIZE_4KB, p * partsize) != (ssize_t) SIZE_4KB) {
+ SIZE_4KB, ((off_t) p) * partsize) != (ssize_t) SIZE_4KB) {
err(ECANCELED,
"Can't write %d b to '%s' p%d", SIZE_4KB, fname, p);
}