zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@math.gatech.edu
Subject: PATCH: 3.1.4 segfault in restore_params
Date: Fri, 9 Oct 1998 08:26:22 -0700	[thread overview]
Message-ID: <981009082623.ZM24827@candle.brasslantern.com> (raw)

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


                 reply	other threads:[~1998-10-09 15:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=981009082623.ZM24827@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).