From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 078705A026E; Tue, 01 Dec 2026 09:24:36 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top 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 Message-ID: <20261201082435.1302453-4-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201082435.1302453-1-sbrivio@redhat.com> References: <20261201082435.1302453-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: WRZHOUSWXGVXARJWJFFRXBL2B7O745WR X-Message-ID-Hash: WRZHOUSWXGVXARJWJFFRXBL2B7O745WR X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier , Jon Maloy X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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) */ -- 2.43.0