($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Finn Behrens <me@kloenk.de>
To: iwd@lists.linux.dev, secure@intel.com
Cc: dev@leona.is, Finn Behrens <me@kloenk.de>
Subject: [PATCH] client: display_completion_matches add 0-byte check
Date: Fri, 10 Nov 2023 11:15:58 +0100	[thread overview]
Message-ID: <20231110101558.30639-1-me@kloenk.de> (raw)

Check that enough space for newline and 0-byte is left in line.
This fixes a buffer overflow on specific completion results.

Reported-By: Leona Maroni <dev@leona.is>
---
 client/display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/client/display.c b/client/display.c
index 8b06ff58..64125934 100644
--- a/client/display.c
+++ b/client/display.c
@@ -633,7 +633,7 @@ static void display_completion_matches(char **matches, int num_matches,
 	l_free(prompt);
 
 	for (index = 1, line_used = 0; matches[index]; index++) {
-		if ((line_used + max_length) > LINE_LEN) {
+		if ((line_used + max_length + 1) >= (LINE_LEN - 1)) {
 			strcpy(&line[line_used], "\n");
 
 			display_text(line);
-- 
2.39.3 (Apple Git-145)


             reply	other threads:[~2023-11-10 10:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10 10:15 Finn Behrens [this message]
2023-11-11 16:25 ` [PATCH] client: display_completion_matches add 0-byte check Denis Kenzior

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=20231110101558.30639-1-me@kloenk.de \
    --to=me@kloenk.de \
    --cc=dev@leona.is \
    --cc=iwd@lists.linux.dev \
    --cc=secure@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).