public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>, Jon Maloy <jmaloy@redhat.com>
Subject: [PATCH 3/3] fwd: Check return value of lineread_get() for /proc/net entries before proceeding
Date: Tue,  1 Dec 2026 09:24:35 +0100	[thread overview]
Message-ID: <20261201082435.1302453-4-sbrivio@redhat.com> (raw)
In-Reply-To: <20261201082435.1302453-1-sbrivio@redhat.com>

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>
---
 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) */
-- 
2.43.0


      parent reply	other threads:[~2026-12-01  8:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  8:24 [PATCH 0/3] Fix Coverity Scan warnings triggered by recent commits Stefano Brivio
2026-12-01  8:24 ` [PATCH 1/3] tcp: Fix return value of tcp_tap_handler() on SO_PEEK_OFF failure Stefano Brivio
2026-12-01  8:24 ` [PATCH 2/3] icmp, tcp, udp: Change Layer-4 protocol handlers to return unsigned Stefano Brivio
2026-12-01  8:24 ` Stefano Brivio [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201082435.1302453-4-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=jmaloy@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).