bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read reads from stale buffer after interrupt


From: Chet Ramey
Subject: Re: read reads from stale buffer after interrupt
Date: Fri, 31 May 2024 10:30:11 -0400
User-agent: Mozilla Thunderbird

On 5/28/24 1:53 AM, Oğuz wrote:
See:

$ while read; do :; done </dev/urandom
^C
$ read </etc/os-release; declare -p REPLY
declare -- 
REPLY=$'\025\241\375%\232\317\002D\214\023\262\262B:\377\255&;\233\350\365\223\022'
$ head -n 1 /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"

The line with ^C means I pressed Ctrl+C while the command above it is
running. It may take a few tries.

Calling zreset() from throw_to_top_level() seems to fix it but I
didn't test much. This is reproducible on 5.2.26 too.

Thanks for the report. Since this occurs when read(2) returns a partial
buffer on an interrupt, I think we can handle it in read_builtin().

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]