From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25033 invoked from network); 26 Aug 1999 07:17:06 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 26 Aug 1999 07:17:06 -0000 Received: (qmail 17506 invoked by alias); 26 Aug 1999 07:16:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7490 Received: (qmail 17499 invoked from network); 26 Aug 1999 07:16:58 -0000 Date: Thu, 26 Aug 1999 09:16:50 +0200 (MET DST) Message-Id: <199908260716.JAA14633@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Wed, 25 Aug 1999 15:37:41 +0000 Subject: Re: PATCH: fix for SEGV Bart Schaefer wrote: > On Aug 24, 2:16pm, Sven Wischnowsky wrote: > } Subject: PATCH: fix for SEGV > } > } ...) ./zsh -f > } % setopt autocd; hash wc=/bin/wc; echo|wc > } > } It'll give you a SEGV in `isreallycom()', trying to look at > } `cn->u.name' which isn't set because for hashed commands `cn->u.cmd' > } is used. > } > } + if (cn->flags & HASHED) > } + return 1; > > Is that really the right fix? I thought the whole point of isreallycom() > was to find cases where the hash table contains a mapping that doesn't > refer to a real executable. I'm not sure it should succeed just because > the mapping was added explicitly. I wasn't sure either and was hoping for a reply. isreallycom() is used only in one place, so we could easily move the extra test there. Bye Sven --- os/exec.c Wed Aug 25 16:21:16 1999 +++ Src/exec.c Thu Aug 26 09:14:13 1999 @@ -615,16 +615,12 @@ int isreallycom(Cmdnam cn) { - if (cn->flags & HASHED) - return 1; - else { - char fullnam[MAXCMDLEN]; + char fullnam[MAXCMDLEN]; - strcpy(fullnam, cn->u.name ? *(cn->u.name) : ""); - strcat(fullnam, "/"); - strcat(fullnam, cn->nam); - return iscom(fullnam); - } + strcpy(fullnam, cn->u.name ? *(cn->u.name) : ""); + strcat(fullnam, "/"); + strcat(fullnam, cn->nam); + return iscom(fullnam); } /**/ @@ -1689,7 +1685,8 @@ char *cmdarg = (char *) peekfirst(args); hn = cmdnamtab->getnode(cmdnamtab, cmdarg); - if (hn && trycd && !isreallycom((Cmdnam)hn)) { + if (hn && trycd && !(((Cmdnam)hn)->flags & HASHED) && + !isreallycom((Cmdnam)hn)) { cmdnamtab->removenode(cmdnamtab, cmdarg); cmdnamtab->freenode(hn); hn = NULL; -- Sven Wischnowsky wischnow@informatik.hu-berlin.de