summary refs log tree commit diff
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2015-01-06 01:01:08 +0100
committerMikael Magnusson <mikachu@gmail.com>2015-01-06 23:45:26 +0100
commit6b79f29fb230e839c97682f9c8648cac2762669e (patch)
tree8b4fed3e376d8bec67cf691f5e2b580b11adb0b5
parenta150563fb049b338983156a5be4ff760a0d79c20 (diff)
downloadzsh-6b79f29fb230e839c97682f9c8648cac2762669e.tar.gz
zsh-6b79f29fb230e839c97682f9c8648cac2762669e.tar.xz
zsh-6b79f29fb230e839c97682f9c8648cac2762669e.zip
34118: Don't crash when writing out history if HOST is unset
Found by Coverity (Issue 1255793).
-rw-r--r--ChangeLog3
-rw-r--r--Src/hist.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 39599afd5..65c049868 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-01-06  Mikael Magnusson  <mikachu@gmail.com>
 
+	* 34118: Src/hist.c: Don't crash when writing out history if
+	HOST is unset
+
 	* 34114: Src/builtin.c: emulate: Handle aborting from mixed
 	-L/-c correctly
 
diff --git a/Src/hist.c b/Src/hist.c
index a0061707c..8ff9eff82 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2801,7 +2801,8 @@ lockhistfile(char *fn, int keep_trying)
 #ifdef HAVE_LINK
 # ifdef HAVE_SYMLINK
 	sprintf(pidbuf, "/pid-%ld/host-", (long)mypid);
-	lnk = bicat(pidbuf, getsparam("HOST"));
+	lnk = getsparam("HOST");
+	lnk = bicat(pidbuf, lnk ? lnk : "");
 	/* We'll abuse fd as our success flag. */
 	while ((fd = symlink(lnk, lockfile)) < 0) {
 	    if (errno != EEXIST) {