Skip to contentSkip to conversation

client: display_completion_matches add 0-byte check

PATCH Applied Finn Behrens 2 participants 2 messages Nov 10, 2023 – Nov 11, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 client: display_completion_matches add 0-byte check

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

---
 client/display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
client/display.c +1 -1
index 8b06ff58..64125934 100644
@@ -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);
Signature · 1 line
2.39.3 (Apple Git-145)
#1 lore raw

Hi Finn,

Quoted 8 lines · Finn Behrens

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

---
  client/display.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Regards,
-Denis