VirtualBox

Changeset 3440 in kBuild


Ignore:
Timestamp:
Sep 10, 2020 11:38:27 AM (5 years ago)
Author:
bird
Message:

kash: Must make sure nfile::expfname is initialized and set to NULL after use, or we risk copying random stuff. Fixed bug in copynodelist.

Location:
trunk/src/kash
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/eval.c

    r3438 r3440  
    104104STATIC void evalsubshell(shinstance *, union node *, int);
    105105STATIC void expredir(shinstance *, union node *);
     106STATIC void expredircleanup(shinstance *, union node *);
    106107STATIC void evalpipe(shinstance *, union node *);
    107108STATIC void evalcommand(shinstance *, union node *, int, struct backcmd *);
     
    251252                evaltree(psh, n->nredir.n, flags);
    252253                popredir(psh);
     254                expredircleanup(psh, n->nredir.redirect);
    253255                break;
    254256        case NSUBSHELL:
     
    473475                psh->exitstatus = waitforjob(psh, jp);
    474476        INTON;
     477        expredircleanup(psh, n->nredir.redirect);
    475478}
    476479
     
    504507                                fixredir(psh, redir, fn.list->text, 1);
    505508                        }
     509                        break;
     510                }
     511        }
     512}
     513
     514STATIC void
     515expredircleanup(shinstance *psh, union node *n)
     516{
     517        for (; n ; n = n->nfile.next) {
     518                struct arglist fn;
     519                fn.lastp = &fn.list;
     520                switch (n->type) {
     521                case NFROMTO:
     522                case NFROM:
     523                case NTO:
     524                case NCLOBBER:
     525                case NAPPEND:
     526                        n->nfile.expfname = NULL;
    506527                        break;
    507528                }
     
    12381259                        evalcommand_parent(psh, flags, args.lastarg, &args.smark, mode, jp,
    12391260                                                           args.pip, backcmd);
     1261                        expredircleanup(psh, cmd->ncmd.redirect);
    12401262                        return; /* at end of routine */
    12411263                }
     
    12481270                evalcommand_doit(psh, cmd, &args);
    12491271        }
     1272        expredircleanup(psh, cmd->ncmd.redirect);
    12501273}
    12511274
  • trunk/src/kash/parser.c

    r3439 r3440  
    12041204
    12051205        np = (union node *)stalloc(psh, sizeof (struct nfile));
     1206        np->nfile.expfname = NULL;
    12061207        if (c == '>') {
    12071208                np->nfile.fd = 1;
     
    17931794                        ppnext = &dst->next;
    17941795                        dst->n = copyparsetree(psh, src->n);
     1796                        src = src->next;
    17951797                }
    17961798        }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette