summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-11-09 15:09:08 +0100
committerLennart Poettering <lennart@poettering.net>2022-11-09 15:09:08 +0100
commit8cee3283f0ca98adccb3066fc4d19a6428958eaf (patch)
tree136b9d019244a78ecf5eb802f1f36eab87a73d1c /src/shared
parentab10dfe0d5101f54501fcbbcfe0267f9720bde1a (diff)
downloadsystemd-8cee3283f0ca98adccb3066fc4d19a6428958eaf.tar.gz
acpi-fpdt: don't accidentally drop signedness of pread() return
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/acpi-fpdt.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/shared/acpi-fpdt.c b/src/shared/acpi-fpdt.c
index c499c7e067..0a91b38ab0 100644
--- a/src/shared/acpi-fpdt.c
+++ b/src/shared/acpi-fpdt.c
@@ -64,7 +64,8 @@ struct acpi_fpdt_boot {
int acpi_get_boot_usec(usec_t *ret_loader_start, usec_t *ret_loader_exit) {
_cleanup_free_ char *buf = NULL;
struct acpi_table_header *tbl;
- size_t l = 0;
+ size_t l;
+ ssize_t ll;
struct acpi_fpdt_header *rec;
int r;
uint64_t ptr = 0;
@@ -109,8 +110,10 @@ int acpi_get_boot_usec(usec_t *ret_loader_start, usec_t *ret_loader_exit) {
if (fd < 0)
return -errno;
- l = pread(fd, &hbrec, sizeof(struct acpi_fpdt_boot_header), ptr);
- if (l != sizeof(struct acpi_fpdt_boot_header))
+ ll = pread(fd, &hbrec, sizeof(struct acpi_fpdt_boot_header), ptr);
+ if (ll < 0)
+ return -errno;
+ if ((size_t) ll != sizeof(struct acpi_fpdt_boot_header))
return -EINVAL;
if (memcmp(hbrec.signature, "FBPT", 4) != 0)
@@ -119,8 +122,10 @@ int acpi_get_boot_usec(usec_t *ret_loader_start, usec_t *ret_loader_exit) {
if (hbrec.length < sizeof(struct acpi_fpdt_boot_header) + sizeof(struct acpi_fpdt_boot))
return -EINVAL;
- l = pread(fd, &brec, sizeof(struct acpi_fpdt_boot), ptr + sizeof(struct acpi_fpdt_boot_header));
- if (l != sizeof(struct acpi_fpdt_boot))
+ ll = pread(fd, &brec, sizeof(struct acpi_fpdt_boot), ptr + sizeof(struct acpi_fpdt_boot_header));
+ if (ll < 0)
+ return -errno;
+ if ((size_t) ll != sizeof(struct acpi_fpdt_boot))
return -EINVAL;
if (brec.length != sizeof(struct acpi_fpdt_boot))