From 4bf88a8081fda888179b4e3022d7b91e2af76ed1 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 22 Apr 2026 02:53:15 +0100 Subject: nvmutil: use uintptr for gbe. check regular file. Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 1f211d6c..61a3737a 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: MIT */ -/* Copyright (c) 2022-2025 Leah Rowe */ +/* Copyright (c) 2022-2026 Leah Rowe */ /* Copyright (c) 2023 Riku Viitanen */ #include @@ -55,7 +55,8 @@ uint8_t hextonum(char chs), rhex(void); uint16_t mac[3] = {0, 0, 0}; ssize_t nf; -size_t partsize, gbe[2]; +size_t partsize; +uintptr_t gbe[2]; uint8_t nvmPartChanged[2] = {0, 0}, do_read[2] = {1, 1}; int flags, rfd, fd, part; @@ -94,8 +95,8 @@ void (*cmd)(void) = NULL; #define reset_caller_errno(return_value) \ do { \ - if (SUCCESS(return_value) && (!errno)) \ - errno = saved_errno; \ + if (SUCCESS(return_value) && (!errno)) \ + errno = saved_errno; \ } while (0) int @@ -199,6 +200,7 @@ openFiles(const char *path) { struct stat st; + xopen(rfd, "/dev/urandom", O_RDONLY); xopen(fd, path, flags); switch(st.st_size) { @@ -213,7 +215,8 @@ openFiles(const char *path) break; } - xopen(rfd, "/dev/urandom", O_RDONLY); + if (if_err(!S_ISREG(st.st_mode), EBADF)) + err(EXIT_FAILURE, "Not a GbE file"); } void -- cgit v1.2.1