diff mbox series

client: display_completion_matches add 0-byte check

Message ID 20231110101558.30639-1-me@kloenk.de (mailing list archive)
State Accepted, archived
Headers show
Series client: display_completion_matches add 0-byte check | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-testrunner fail test-runner - FAIL: testDPP,testPSK-roam

Commit Message

Finn Behrens Nov. 10, 2023, 10:15 a.m. UTC
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(-)

Comments

Denis Kenzior Nov. 11, 2023, 4:25 p.m. UTC | #1
Hi Finn,

On 11/10/23 04:15, Finn Behrens wrote:
> 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(-)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

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);