Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Cygwin/MSYS2: Trouble converting relative paths from / using :a or :A



Jun T wrote on Wed, Nov 17, 2021 at 18:39:12 +0900:
> 
> > 2021/11/15 17:44、I wrote:
> 
> > # When is it possible that the return value of zgetcwd() ends with '/' but is not
> > # equal to just "/"?
> 
> Now I think that the return value of zgetcwd() ('here') can end with '/'
> only if strlen(here)==1, so we need not metafy 'here'.
> Am I correct?
> 

I don't know.

> > +	char *here = zgetcwd();
> > +	if (here[strlen(here)-1] != '/')
> > +	    *junkptr = zhtricat(metafy(here, -1, META_HEAPDUP), "/", *junkptr);
> > +	else
> > +	    *junkptr = dyncat(here, *junkptr);
> 
> The same code appears at lines 932 of hist.c, and line 4501 of subst.c.

This isn't a new issue in your patch, but I'd like to ask it anyway:

Can zgetcwd() return an empty string?  If so, the expression in the
condition will trigger undefined behaviour.

Cheers,

Daniel




Messages sorted by: Reverse Date, Date, Thread, Author