Merge pull request #29601 from yuwata/mmap-check-overflow

mmap: check offset and size more carefully
This commit is contained in:
Luca Boccassi
2023-10-24 12:20:04 +01:00
committed by GitHub
27 changed files with 365 additions and 82 deletions
+2 -2
View File
@@ -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))
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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);