bug-bash
[Top][All Lists]
Advanced

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

Re: param expansion with single-character special vars in the environmen


From: Piotr Grzybowski
Subject: Re: param expansion with single-character special vars in the environment
Date: Sun, 15 May 2016 01:20:22 +0200

hi,

 there are two problems: not checking NULL returned by bind_variable, and not 
allowing to enter valid_nameref_value.
 Since bind_variable can return NULL, that should be checked everywhere.
 Also NULL and empty strings are not valid nameref values, so the check should 
be added in valid_nameref_value (at the moment passing NULL as first argument 
sigsegs (due to valid_array_reference not checking if name is NULL)).
 The attached patch fixes errors in your report (please note that if in 
variables.c:2877 also can be simplified) and the above.
 Concerning exporting the namerefs, we are a bit back at our earlier discussion 
and patch proposal (export -r).

cheers,
pg


Attachment: check_NULL_after_bind_allow_to_enter_valid_nameref_value_with_empty_string.patch
Description: Binary data





On 14 May 2016, at 18:41, Grisha Levit wrote:

> On Mon, May 2, 2016 at 2:30 PM, Chet Ramey <chet.ramey@case.edu> wrote:
> 
> 
> 
> I ended up writing a new function: valid_nameref_value(name, flags) which
> I can customize to serve this purpose.
> 
> 
> Looks like this ends up getting bypassed in some cases when the value is an 
> empty string:
> 
> declare -n r; : ${r=}
> declare -n r; r=""
> declare -n r; printf -v r ''
> 
> r=
> ""; declare
>  -n r
> 
> Each of these result in:
> 
> $ declare
>  -p r
> 
> declare -n r=""
> Which itself is invalid:
> 
> $ declare -n r=""
> 
> bash: 
> declare: `': not a valid identifier
> This new nameref takes assignments but doesn’t seem to do anything with them. 
> It does cause at least one segfault though:
> 
> $ declare -n r; r=""
> 
> $ 
> export r    # or readonly r
> 
> Segmentation fault: 
> 11


reply via email to

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