From f4c69b552ee9a49d322ee566c43e771c56121137 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 1 Dec 2026 03:07:36 +0100 Subject: 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 --- fwd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fwd.c b/fwd.c index add01c0..b2dc074 100644 --- a/fwd.c +++ b/fwd.c @@ -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) */ -- cgit v1.2.3