Re: read reads from stale buffer after interrupt

2024-05-31 Thread Chet Ramey
On 5/28/24 1:53 AM, Oğuz wrote: See: $ while read; do :; done 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

Re: [PATCH] bind_assoc_variable: free key if cannot assign

2024-05-31 Thread Chet Ramey
On 5/30/24 5:30 PM, Grisha Levit wrote: Avoid leaking expansion of `x' in `declare -Ar A; A[x]=' Thanks for the report. I think a more appropriate place to fix this is assign_array_element_internal(), since that's where the key is allocated. Chet -- ``The lyf so short, the craft so long to le

Re: read reads from stale buffer after interrupt

2024-05-31 Thread Oğuz
On Friday, May 31, 2024, Chet Ramey wrote: > > 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(). > Okay, handle how though? Leave the file offset at the last byte read before the interrupt or where the las

Re: read reads from stale buffer after interrupt

2024-05-31 Thread Chet Ramey
On 5/31/24 11:57 AM, Oğuz wrote: On Friday, May 31, 2024, Chet Ramey > wrote: 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(). Okay, handle how though? Leave the file

[PATCH] cond expr: cleanup on errors

2024-05-31 Thread Grisha Levit
Two minor leak fixes for conditional command error conditions: If a WORD token is read when COND_AND, COND_OR, COND_END, or a binary operator are expected, the allocated WORD_DESC is leaked. If a conditional command has a syntax error, the allocated COMMAND is leaked. --- parse.y | 14 ++

[PATCH] coproc: do not leak name

2024-05-31 Thread Grisha Levit
When a named coproc is created, the name string and associated WORD_DESC are leaked. --- parse.y | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parse.y b/parse.y index d39d6737..fe5038be 100644 --- a/parse.y +++ b/parse.y @@ -1103,6 +1103,7 @@ coproc: COPROC shell_command

[PATCH] expand_word_internal: fix leak with W_NOSPLIT2

2024-05-31 Thread Grisha Levit
Free temporary list allocated when exapnding `$@' in bash -c 'IFS=:; : ${_+$@}' _ X --- subst.c | 1 + 1 file changed, 1 insertion(+) diff --git a/subst.c b/subst.c index 3faa4068..c56d2434 100644 --- a/subst.c +++ b/subst.c @@ -12144,6 +12144,7 @@ finished_with_string: retu

[PATCH] exec: free args on failed exec

2024-05-31 Thread Grisha Levit
The comment describing why this wasn't done has been there since the start of the repo's history and AFAICT it is not accurate anymore, as shell_execve only calls realloc when it's going to longjmp rather than return. Fixes leak in bash -O execfail -c 'exec /; :' --- builtins/exec.def | 4 --