zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.4 segfault in restore_params
@ 1998-10-09 15:26 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 1998-10-09 15:26 UTC (permalink / raw)
  To: zsh-workers

The core dump is obviously a null pointer dereference, so the following is
a minimal fix, but I wonder how the null value got into the restorelist in
the first place?  (Circumstances below the patch.)

Index: Src/exec.c
--- exec.c	1998/09/18 17:06:53	1.2
+++ exec.c	1998/10/09 15:22:54
@@ -1971,8 +1971,8 @@
 		}
 	    } else
 		paramtab->addnode(paramtab, pm->nam, pm);
-	    if (pm->flags & PM_EXPORTED)
-		pm->env = addenv(pm->nam, getsparam(pm->nam));
+	    if ((pm->flags & PM_EXPORTED) && ((s = getsparam(pm->nam))))
+		pm->env = addenv(pm->nam, s);
 	}
     }
 }



I have a little function called "cvs":
----------
#! /usr/local/bin/zsh -f
cvsroot
case $1 in
diff|log|status)
    command cvs -n $* ;;
*)
    command cvs $* ;;
esac
----------

It calls a function called "cvsroot" to determine the correct value for
the CVSROOT environment variable:
----------
#!/usr/local/bin/zsh -f
if [[ ! -d CVS ]]
then
    return 1
    exit 1
fi
if [[ -z "$CVSROOT" || ! -d "$CVSROOT"/CVSROOT ]]
then
    if [[ -f CVS/Root ]]
    then
	CVSROOT=$(<CVS/Root)
    else
	CVSROOT=$(<CVS/Repository)
	while [[ ! -d $CVSROOT/CVSROOT && $CVSROOT != $CVSROOT:h ]]
	do
	    CVSROOT=$CVSROOT:h
	done
    fi
    if [[ ! -d "$CVSROOT"/CVSROOT ]]
    then
	unset CVSROOT
    fi
fi
if [[ -n "$CVSROOT" ]]
then
    if [[ $- != *f* ]]
    then
	export CVSROOT
    else
	echo setenv CVSROOT $CVSROOT
    fi
fi
----------

(Yes, I know the above isn't necessary with some recent versions of cvs.)

I was using this repeatedly from inside 3.1.4 for the first time yesterday,
and after 5 or 6 calls -- I'm not exactly sure how many worked fine -- it
completed the cvs command and then, apparently on exit from the function,
zsh segfaulted.

It's possible that I was in a directory with no CVS subdirectory and that
I'd therefore prefixed the command with CVSROOT=..., but I don't think so.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-10-09 15:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-09 15:26 PATCH: 3.1.4 segfault in restore_params Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).