bug-bash
[Top][All Lists]
Advanced

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

Re: segfaults with function attribute manipulations


From: Chet Ramey
Subject: Re: segfaults with function attribute manipulations
Date: Tue, 8 Jan 2019 16:27:21 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 1/8/19 4:36 AM, Grisha Levit wrote:
> A couple silly function attribute manipulations lead to situations that
> result in segfaults:

Thanks for the report.

> 
> $ f() { :; }; declare -Af f; declare -pf f
> [ segfault ]
> 
> diff --git a/builtins/setattr.def b/builtins/setattr.def
> index 251bcacb..1a828291 100644
> --- a/builtins/setattr.def
> +++ b/builtins/setattr.def
> @@ -474,9 +474,9 @@ show_var_attributes (var, pattr, nodefs)
>  #if defined (ARRAY_VARS)
>    if (invisible_p (var) && (array_p (var) || assoc_p (var)))
>      printf ("%s\n", var->name);
> -  else if (array_p (var))
> +  else if (array_p (var) && function_p (var) == 0)
>      print_array_assignment (var, 0);
> -  else if (assoc_p (var))
> +  else if (assoc_p (var) && function_p (var) == 0)
>      print_assoc_assignment (var, 0);
>    else
>  #endif
> 
> (Maybe the better solution would be to prevent meaningless attributes from
> getting assigned to functions in the first place, but they seem harmless
> otherwise).

I prefer:

$ ./bash ./x19
./x19: line 1: declare: f: -A? Oh, come on.
f ()
{
    :
}


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



reply via email to

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