[PATCH] input: Fix preadbuffer loop when libedit is enabled
Herbert Xu <[email protected]> Thu, 12 Mar 2026 19:02:17 +0900
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Mar 01, 2026 at 07:53:22PM +0200, Jyri-Matti Lähteenmäki wrote:
>
> Git bisect says that commit a065467315dc5f2f312f7e6f1d2e9d05a77b3cb7
> ("input: Move newline loop into preadbuffer") is the first bad one (I
> probably made some mistake earlier when I said commit 6574... would work.):
Indeed that was the buggy commit:
---8<---
The preadbuffer loop to get whole lines is broken because it never
sets lleft before calling preadfd, the latter relies on it to
correctly position the read buffer.
Fix this by setting lleft before preadfd is called.
Reported-by: Jyri-Matti Lähteenmäki <[email protected]>
Fixes: a065467315dc ("input: Move newline loop into preadbuffer")
Signed-off-by: Herbert Xu <[email protected]>
diff --git a/src/input.c b/src/input.c
index c36d120..0c2c066 100644
--- a/src/input.c
+++ b/src/input.c
@@ -386,6 +386,7 @@ eof:
again:
nr = q - parsefile->nextc;
+ input_set_lleft(parsefile, nr);
more = preadfd();
q = parsefile->nextc + nr;
if (more <= 0) {
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt