diff options
| author | Stefano Brivio <sbrivio@redhat.com> | 2026-12-01 03:07:36 +0100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-12-02 22:59:29 +0100 |
| commit | f4c69b552ee9a49d322ee566c43e771c56121137 (patch) | |
| tree | 97e970dfb619dd14dfa51267b92ad98d48e30c06 | |
| parent | 8ce30019e739080a5a8292d567b8e48631f2f6fa (diff) | |
| download | passt-f4c69b552ee9a49d322ee566c43e771c56121137.tar passt-f4c69b552ee9a49d322ee566c43e771c56121137.tar.gz passt-f4c69b552ee9a49d322ee566c43e771c56121137.tar.bz2 passt-f4c69b552ee9a49d322ee566c43e771c56121137.tar.lz passt-f4c69b552ee9a49d322ee566c43e771c56121137.tar.xz passt-f4c69b552ee9a49d322ee566c43e771c56121137.tar.zst passt-f4c69b552ee9a49d322ee566c43e771c56121137.zip | |
fwd: Check return value of lineread_get() for /proc/net entries before proceeding
Not really a functional issue as we would detect malformed entries in
/proc/net files in the loop just after this point, but Coverity Scan
realised, after cfca8d1daa4b ("conf: Follow changes to the host
nameserver used for DNS forwarding"), that we don't check the return
value of lineread_get() in procfs_scan_listen().
Check it and add a separate warning if we can't read even a single
line from the file.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | fwd.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -652,7 +652,11 @@ static void procfs_scan_listen(int fd, unsigned int lstate, uint8_t *map) } lineread_init(&lr, fd); - lineread_get(&lr, &line); /* throw away header */ + if (lineread_get(&lr, &line) <= 0) { /* throw away header */ + warn("Failed to read /proc/net file"); + return; + } + while (lineread_get(&lr, &line) > 0) { /* != 2 if conversion fails */ /* NOLINTNEXTLINE(bugprone-unchecked-string-to-number-conversion,cert-err34-c) */ |
