Hi David & Co,

a while ago, the code in path_nextcomp() (src/cmd/ksh93/sh/path.c)
was changed from

        if(pp->flags&PATH_SKIP)
                continue;

to

        if(pp->flags&PATH_SKIP)
                return(ppnext);

Because of this change, path_nextcomp may return without doing
any work, i.e. not changing the PATH_OFFSET element.

This breaks path_opentype(), which does the following:

        pp = path_nextcomp(shp,oldpp=pp,name,0);
        while(oldpp && (oldpp->flags&PATH_SKIP))
                oldpp = oldpp->next;
        if(fun && (!oldpp || !(oldpp->flags&PATH_FPATH)))
                continue;
        if((fd = 
sh_open(path_relative(shp,stkptr(shp->stk,PATH_OFFSET)),O_RDONLY|O_cloexec,0)) 
>= 0)

if pp points to a element with PATH_SKIP set, path_nextcomp will
return earlt and the sh_open returns some old element with by
chance is in PATH_OFFSET. In the bug report I got this caused
". script" to process some different file...

So, two questions:

1) why was the continue changed to return(ppnext)?

2) I fixed the issue by changing path_opentype to

        pp = path_nextcomp(shp,oldpp=pp,name,0);
        if(oldpp && (oldpp->flags&PATH_SKIP))
                continue;
        ...

is this the correct fix?

(This was reported for ksh93u, but the code in ksh93v seems to be
unchanged.)

Thanks,
  Michael.

-- 
Michael Schroeder                                   m...@suse.de
SUSE LINUX Products GmbH,  GF Jeff Hawn, HRB 16746 AG Nuernberg
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}
_______________________________________________
ast-developers mailing list
ast-developers@lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to