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: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH] passt-repair: Fix off-by-one in check for number of file descriptors
Date: Wed, 12 Feb 2025 01:08:54 +0100	[thread overview]
Message-ID: <20250212000854.506036-1-sbrivio@redhat.com> (raw)

Actually, 254 is too many, but 253 isn't.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 passt-repair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/passt-repair.c b/passt-repair.c
index 0f03506..ba0c48b 100644
--- a/passt-repair.c
+++ b/passt-repair.c
@@ -132,7 +132,7 @@ loop:
 	/* No inverse formula for CMSG_LEN(x), and building one with CMSG_LEN(0)
 	 * works but there's no guarantee it does. Search the whole domain.
 	 */
-	for (i = 1; i < SCM_MAX_FD; i++) {
+	for (i = 1; i <= SCM_MAX_FD; i++) {
 		if (CMSG_LEN(sizeof(int) * i) == cmsg->cmsg_len) {
 			n = i;
 			break;
-- 
@@ -132,7 +132,7 @@ loop:
 	/* No inverse formula for CMSG_LEN(x), and building one with CMSG_LEN(0)
 	 * works but there's no guarantee it does. Search the whole domain.
 	 */
-	for (i = 1; i < SCM_MAX_FD; i++) {
+	for (i = 1; i <= SCM_MAX_FD; i++) {
 		if (CMSG_LEN(sizeof(int) * i) == cmsg->cmsg_len) {
 			n = i;
 			break;
-- 
2.43.0


                 reply	other threads:[~2025-02-12  0:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250212000854.506036-1-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --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).