bug-bash
[Top][All Lists]
Advanced

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

text similar to JSON can cause memory of bash to become abnormally large


From: wang yuhang
Subject: text similar to JSON can cause memory of bash to become abnormally large
Date: Thu, 25 May 2023 09:39:12 +0800

hi 
 
I accidentally copied a section of JSON text to the terminal and executed it, 
which resulted in a system crash.Bash version is 5.1.8. 
 
Later, I reproduced it and found that when I executed the following command, 
the memory usage of bash became very large. 
 
$ 
[{"key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1"},{"key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1"},{"key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1"},{"key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1","key":"1"}]
 
 
Through tracking the code, it was found that in the brace_expand_word_list 
function, there is a continuous recursive execution of the brace_expand 
function, which causes the len2 variable of function array_concat to become 
abnormally large, and then a large amount of memory will be malloced based on 
the value of len2 
 
This may be a normal manifestation of bash rather than a problem. But in the 
case of user misoperation, it can cause system crashes, so I still hope that 
this situation can be improved

 

reply via email to

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