mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
util: make file_read() 64bit offset safe
File offsets in UEFI are 64bit on all archs, hence let's use that typo too, and not create artificial confusion around types.
This commit is contained in:
parent
ba694646ea
commit
9573ab8f5a
@ -330,7 +330,14 @@ EFI_STATUS chunked_read(EFI_FILE *file, size_t *size, void *buf) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, size_t off, size_t size, char **ret, size_t *ret_size) {
|
||||
EFI_STATUS file_read(
|
||||
EFI_FILE *dir,
|
||||
const char16_t *name,
|
||||
uint64_t off,
|
||||
size_t size,
|
||||
char **ret,
|
||||
size_t *ret_size) {
|
||||
|
||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
EFI_STATUS err;
|
||||
@ -350,6 +357,9 @@ EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, size_t off, size_t siz
|
||||
if (err != EFI_SUCCESS)
|
||||
return err;
|
||||
|
||||
if (info->FileSize > SIZE_MAX)
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
|
||||
size = info->FileSize;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ char16_t *xstr8_to_path(const char *stra);
|
||||
char16_t *mangle_stub_cmdline(char16_t *cmdline);
|
||||
|
||||
EFI_STATUS chunked_read(EFI_FILE *file, size_t *size, void *buf);
|
||||
EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, size_t off, size_t size, char **content, size_t *content_size);
|
||||
EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, uint64_t off, size_t size, char **content, size_t *content_size);
|
||||
|
||||
static inline void file_closep(EFI_FILE **handle) {
|
||||
if (!*handle)
|
||||
|
Loading…
Reference in New Issue
Block a user