diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-01-07 12:46:02 +1100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-01-10 19:27:40 +0100 |
| commit | 0bd2e6883d560c038e49a3cf68984d63f87ca67a (patch) | |
| tree | 97bce9580c4da89be997f28f209c49aaf6328ec7 | |
| parent | 2aa63237109b97a55c85e4c86c72db0d055bfe7a (diff) | |
| download | passt-0bd2e6883d560c038e49a3cf68984d63f87ca67a.tar passt-0bd2e6883d560c038e49a3cf68984d63f87ca67a.tar.gz passt-0bd2e6883d560c038e49a3cf68984d63f87ca67a.tar.bz2 passt-0bd2e6883d560c038e49a3cf68984d63f87ca67a.tar.lz passt-0bd2e6883d560c038e49a3cf68984d63f87ca67a.tar.xz passt-0bd2e6883d560c038e49a3cf68984d63f87ca67a.tar.zst passt-0bd2e6883d560c038e49a3cf68984d63f87ca67a.zip | |
util: Be more defensive about buffer overruns in read_file()
clang-21.1.7 complains about read_file(), thinking that total_read might
come to exceed buf_size, leading to an out of bounds access at the end of
the function. In fact, the semantics of read()'s return mean this can't
ever happen. But we already have to check for the total_read == buf_size
case, so it's basically free to change it to >= and suppress the error.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | util.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -715,7 +715,7 @@ static ssize_t read_file(const char *path, char *buf, size_t buf_size) close(fd); - if (total_read == buf_size) { + if (total_read >= buf_size) { buf[buf_size - 1] = '\0'; return -ENOBUFS; } |
