Linux NFS development
 help / color / mirror / Atom feed
From: Krzesimir Nowak <qdlacz@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: qdlacz@gmail.com, Krzesimir Nowak <knowak@microsoft.com>,
	Michalis Vasileiadis <vmihalis.tmd@gmail.com>
Subject: [PATCH] rpcinfo: stack buffer overflow in rpcinfo rpcbdump()
Date: Fri, 28 Aug 2026 17:38:16 +0200	[thread overview]
Message-ID: <20260828153829.1034658-1-knowak@microsoft.com> (raw)

rpcinfo's rpcbdump() formats a server-controlled list of versions into
a fixed size buffer with sprintf(). A malicious server returning a
large number of versions may overflow it.

Reported-by: Michalis Vasileiadis <vmihalis.tmd@gmail.com>
Signed-off-by: Krzesimir Nowak <knowak@microsoft.com>
---
 src/rpcinfo.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/rpcinfo.c b/src/rpcinfo.c
index 30d535e..9917913 100644
--- a/src/rpcinfo.c
+++ b/src/rpcinfo.c
@@ -958,17 +958,19 @@ rpcbdump (
       for (rs = rs_head; rs; rs = rs->next)
 	{
 	  size_t netidmax = sizeof(buf) - 1;
-	  char *p = buf;
+	  int l = 0;
 
 	  printf ("%10ld  ", rs->prog);
 	  for (vl = rs->vlist; vl; vl = vl->next)
 	    {
-	      sprintf (p, "%d", vl->vers);
-	      p = p + strlen (p);
+	      l += printf ("%d", vl->vers);
 	      if (vl->next)
-		sprintf (p++, ",");
+		l += printf (",");
 	    }
-	  printf ("%-10s", buf);
+	  if (l < 10)
+	    printf("%*s", 10 - l, " ");
+	  else
+	    printf(" ");
 	  buf[0] = '\0';
 
           for (nl = rs->nlist; nl; nl = nl->next)
-- 
2.54.0


                 reply	other threads:[~2026-08-28 15:38 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=20260828153829.1034658-1-knowak@microsoft.com \
    --to=qdlacz@gmail.com \
    --cc=knowak@microsoft.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=vmihalis.tmd@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox