From: Lennart Poettering Date: Fri, 6 Feb 2026 21:31:53 +0000 (+0100) Subject: bootctl: add comments emphasizing that certain functions do not touch the file read... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a537c5e4b8c424453f629506fb2188b5b6e2e0e4;p=thirdparty%2Fsystemd.git bootctl: add comments emphasizing that certain functions do not touch the file read pointer --- diff --git a/src/bootctl/bootctl-install.c b/src/bootctl/bootctl-install.c index 2d9a151212d..8399a2da721 100644 --- a/src/bootctl/bootctl-install.c +++ b/src/bootctl/bootctl-install.c @@ -490,6 +490,8 @@ static int version_check(int fd_from, const char *from, int fd_to, const char *t assert(fd_to >= 0); assert(to); + /* Does not reposition file offset */ + r = get_file_version(fd_from, &a); if (r == -ESRCH) return log_notice_errno(r, "Source file \"%s\" does not carry version information!", from); diff --git a/src/bootctl/bootctl-util.c b/src/bootctl/bootctl-util.c index 23b8786f1d8..071accb77d6 100644 --- a/src/bootctl/bootctl-util.c +++ b/src/bootctl/bootctl-util.c @@ -75,6 +75,8 @@ int get_file_version(int fd, char **ret) { assert(fd >= 0); assert(ret); + /* Does not reposition file offset (as it uses mmap()) */ + if (fstat(fd, &st) < 0) return log_error_errno(errno, "Failed to stat EFI binary: %m"); diff --git a/src/shared/pe-binary.c b/src/shared/pe-binary.c index 97e5ba51c78..0a1b93118c2 100644 --- a/src/shared/pe-binary.c +++ b/src/shared/pe-binary.c @@ -12,6 +12,8 @@ #include "string-table.h" #include "string-util.h" +/* Note: none of these function change the file position of the provided fd, as they use pread() */ + bool pe_header_is_64bit(const PeHeader *h) { assert(h);