aports/main/busybox/0032-lineedit-fix-some-tab-completions-written-to-stdout.patch
Sertonix 3d6d332cfd main/busybox: fix input overflow
As far as I know the implicit '\n' doesn't work on stderr so it needs to
be written explicetly.

Fixes <43a8331c40> main/busybox: fix some tab completions written to stdout
2024-11-03 16:50:47 +00:00

46 lines
1.5 KiB
Diff

From 9da8d772bafb45b04c34b9901b1c16ad0e439ac5 Mon Sep 17 00:00:00 2001
From: Sertonix <sertonix@posteo.net>
Date: Wed, 30 Oct 2024 14:09:36 +0100
Subject: [PATCH] lineedit: fix some tab completions written to stdout
In fd47f056765 (lineedit: print prompt and editing operations to stderr)
some output was left printing to stdout. This can causes a race condition
between stderr and stdout which in some cases leads to output written in
the wrong places.
Downstream issue: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16566
Fixes: fd47f056765
Signed-off-by: Sertonix <sertonix@posteo.net>
---
libbb/lineedit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 151208c1c..066087364 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -451,7 +451,7 @@ static void put_cur_glyph_and_inc_cursor(void)
* have automargin (IOW: it is moving cursor to next line
* by itself (which is wrong for VT-10x terminals)),
* this will break things: there will be one extra empty line */
- puts("\r"); /* + implicit '\n' */
+ fprintf(stderr, "\r\n");
#else
/* VT-10x terminals don't wrap cursor to next line when last char
* on the line is printed - cursor stays "over" this char.
@@ -1170,9 +1170,9 @@ static void showfiles(void)
);
}
if (ENABLE_UNICODE_SUPPORT)
- puts(printable_string(matches[n]));
+ fprintf(stderr, "%s\n", printable_string(matches[n]));
else
- puts(matches[n]);
+ fprintf(stderr, "%s\n", matches[n]);
}
}
--
2.46.2