Merge pull request #29601 from yuwata/mmap-check-overflow
mmap: check offset and size more carefully
This commit is contained in:
@@ -588,7 +588,7 @@ static int parse_core(int fd, const char *executable, char **ret, JsonVariant **
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
return log_warning_errno(errno, "Failed to seek to beginning of the core file: %m");
|
||||
|
||||
if (ret && !memstream_init(&c.m))
|
||||
@@ -644,7 +644,7 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
return log_warning_errno(errno, "Failed to seek to beginning of the ELF file: %m");
|
||||
|
||||
if (ret && !memstream_init(&c.m))
|
||||
|
||||
@@ -151,7 +151,7 @@ int machine_id_setup(const char *root, bool force_transient, sd_id128_t machine_
|
||||
}
|
||||
|
||||
if (writable) {
|
||||
if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
return log_error_errno(errno, "Failed to seek %s: %m", etc_machine_id);
|
||||
|
||||
if (ftruncate(fd, 0) < 0)
|
||||
|
||||
@@ -4594,7 +4594,7 @@ static int tpm2_userspace_log(
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to format JSON: %m");
|
||||
|
||||
if (lseek(fd, 0, SEEK_END) == (off_t) -1)
|
||||
if (lseek(fd, 0, SEEK_END) < 0)
|
||||
return log_debug_errno(errno, "Failed to seek to end of JSON log: %m");
|
||||
|
||||
r = loop_write(fd, f, SIZE_MAX);
|
||||
|
||||
Reference in New Issue
Block a user