Re: expand: Fix scanright zero handling when fnmatch is disabled

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

 



On Sun, Mar 09, 2025 at 04:51:53PM +0800, Herbert Xu wrote:
> Johannes Altmanninger <aclopte@xxxxxxxxx> wrote:
> > I noticed another regression in c5bf970 (expand: Add multi-byte
> > support to pmatch, 2024-06-02).
> > 
> > This command now prints "abc-def" but used to print "ef".
> > 
> >        x=abc-def
> >        y="${x##*d}"
> >        echo "$y"
> 
> Fix this by setting s to the correct value in scanright based
> on FNMATCH_IS_ENABLED.
> 
> Fixes: c5bf9702ea11 ("expand: Add multi-byte support to pmatch")
> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> 
> diff --git a/src/expand.c b/src/expand.c
> index 7a30648..0066e1a 100644
> --- a/src/expand.c
> +++ b/src/expand.c
> @@ -650,7 +650,7 @@ static char *scanright(char *startp, char *endp, char *rmesc, char *rmescend,
>  
>  		if (zero) {
>  			*s = '\0';
> -			s = rmesc;
> +			s = FNMATCH_IS_ENABLED ? rmesc : startp;

Seems to work, thanks. I can go back to running master now (with
https://lore.kernel.org/dash/ZzlT_1CY5AjxtqAs@xxxxxxxxxxxxxxxxxxx/
applied too)




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux