[PATCH 1/3] libshell: fix subtle section parsing bug

Artem Bityutskiy dedekind1 at gmail.com
Wed May 28 00:10:20 PDT 2014


Hi Jacob,

I never had time for this, but wanted to let you know the following.

1. We carry a copy of rather old libshell. The upstream repo of it is
this:

git://git.altlinux.org/people/legion/packages/libshell.git

We may want to look there and update sometimes.

2. The libshell contact is: Alexey Gladkov ⟨legion at altlinux.org⟩
May be it makes sense to CC Alexey in cases like this. Let me do just
that.

Thanks!


On Tue, 2014-05-27 at 15:17 -0700, Jacob Keller wrote:
> The libshell ini_config_get and ini_config_is_set functions were broken
> in a subtle way, due to allowance of variables in a section which may
> not be defined. When we encountered the [section] tag that matched our
> given section, we enabled reading each line to check the variables.
> However, we never disabled the section once we found it, so it was
> possible for a variable defined in a forthcoming section to be returned,
> if we didn't define the variable in the expected section.
> 
> This resulted in several subtle bugs regarding project configuration
> especially regarding the [default] section, and multiple projects. The
> fix for this, is simply to disable section processing upon section
> change. I thought about possibly just exiting, if we've found our
> section and it changes. However, that is a bit more complex logic, and
> this fix allows for having the same section twice, which might be a
> little confusing, but I think it's acceptable.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
> ---
>  helpers/libshell/shell-ini-config | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/helpers/libshell/shell-ini-config b/helpers/libshell/shell-ini-config
> index ba0bfbde777a..ffce51598876 100644
> --- a/helpers/libshell/shell-ini-config
> +++ b/helpers/libshell/shell-ini-config
> @@ -21,6 +21,8 @@ ini_config_get() {
>  
>  		case "$str" in
>  			"["*"]")
> +				# Reset section processing on section change
> +				sect=
>  				[ "$str" != "[$section]" ] ||
>  					sect=1
>  				;;
> @@ -52,6 +54,8 @@ ini_config_is_set()
>  
>  		case "$str" in
>  			"["*"]")
> +				# Reset section processing on section change
> +				sect=
>  				[ "$str" != "[$section]" ] ||
>  					sect=1
>  				;;

-- 
Best Regards,
Artem Bityutskiy




More information about the aiaiai mailing list