commit: 4642124c12532cad1afd463589b8ebd0386b06be
parent: 9a200fcedcf81b4fbe833b4a2386bd835265fe93
author: Brian Callahan <bcallah@openbsd.org>
date: Fri, 1 Nov 2019 23:26:02 -0400
Update to latest ksh code; fixes a hard failure with history.
2 files changed, 48 insertions(+), 41 deletions(-)
diff --git a/CVS/Entries b/CVS/Entries
@@ -6,41 +6,41 @@
/edit.c/1.69/Result of merge//
/eval.c/1.65/Result of merge//
/exec.c/1.74/Result of merge//
-/history.c/1.82/Result of merge//
/main.c/1.98/Result of merge//
/misc.c/1.73/Result of merge//
/tty.c/1.18/Result of merge+Tue Jul 23 23:36:05 2019//
/io.c/1.38/Result of merge//
-/CONTRIBUTORS/1.11/Sun Aug 25 17:55:05 2019//
-/LEGAL/1.2/Sun Aug 25 17:55:05 2019//
-/Makefile/1.39/Sun Aug 25 17:56:28 2019//
-/NOTES/1.16/Sun Aug 25 17:55:05 2019//
-/PROJECTS/1.9/Sun Aug 25 17:55:05 2019//
-/README/1.16/Sun Aug 25 17:56:28 2019//
-/alloc.c/1.19/Sun Aug 25 17:55:05 2019//
-/c_ksh.c/1.62/Sun Aug 25 17:55:05 2019//
-/c_sh.c/1.63/Sun Aug 25 17:55:05 2019//
-/c_test.h/1.4/Sun Aug 25 17:55:05 2019//
-/c_ulimit.c/1.29/Sun Aug 25 17:55:05 2019//
-/edit.h/1.12/Sun Aug 25 17:55:05 2019//
-/expand.h/1.15/Sun Aug 25 17:55:05 2019//
-/expr.c/1.34/Sun Aug 25 17:55:05 2019//
-/jobs.c/1.61/Sun Aug 25 17:55:05 2019//
-/ksh.1/1.207/Sun Aug 25 17:55:05 2019//
-/lex.c/1.78/Sun Aug 25 17:55:05 2019//
-/lex.h/1.21/Sun Aug 25 17:55:05 2019//
-/mail.c/1.27/Sun Aug 25 17:55:05 2019//
-/path.c/1.23/Sun Aug 25 17:55:05 2019//
-/sh.1/1.152/Sun Aug 25 17:55:05 2019//
-/shf.c/1.34/Sun Aug 25 17:55:05 2019//
-/shf.h/1.8/Sun Aug 25 17:55:05 2019//
-/syn.c/1.39/Sun Aug 25 17:55:05 2019//
-/table.c/1.25/Sun Aug 25 17:55:05 2019//
-/table.h/1.15/Sun Aug 25 17:55:05 2019//
-/trap.c/1.33/Sun Aug 25 17:55:05 2019//
-/tree.c/1.34/Sun Aug 25 17:55:05 2019//
-/tree.h/1.12/Sun Aug 25 17:55:05 2019//
-/tty.h/1.6/Sun Aug 25 17:55:05 2019//
-/version.c/1.12/Sun Aug 25 17:55:05 2019//
-/vi.c/1.56/Sun Aug 25 17:55:05 2019//
+/CONTRIBUTORS/1.11/Sat Nov 2 03:25:39 2019//
+/LEGAL/1.2/Sat Nov 2 03:25:39 2019//
+/Makefile/1.39/Sat Nov 2 03:25:48 2019//
+/NOTES/1.16/Sat Nov 2 03:25:39 2019//
+/PROJECTS/1.9/Sat Nov 2 03:25:39 2019//
+/README/1.16/Sat Nov 2 03:25:48 2019//
+/alloc.c/1.19/Sat Nov 2 03:25:39 2019//
+/c_ksh.c/1.62/Sat Nov 2 03:25:39 2019//
+/c_sh.c/1.63/Sat Nov 2 03:25:39 2019//
+/c_test.h/1.4/Sat Nov 2 03:25:39 2019//
+/c_ulimit.c/1.29/Sat Nov 2 03:25:39 2019//
+/edit.h/1.12/Sat Nov 2 03:25:39 2019//
+/expand.h/1.15/Sat Nov 2 03:25:39 2019//
+/expr.c/1.34/Sat Nov 2 03:25:39 2019//
+/history.c/1.84/Result of merge//
+/jobs.c/1.61/Sat Nov 2 03:25:39 2019//
+/ksh.1/1.207/Sat Nov 2 03:25:39 2019//
+/lex.c/1.78/Sat Nov 2 03:25:39 2019//
+/lex.h/1.21/Sat Nov 2 03:25:39 2019//
+/mail.c/1.27/Sat Nov 2 03:25:39 2019//
+/path.c/1.23/Sat Nov 2 03:25:39 2019//
+/sh.1/1.152/Sat Nov 2 03:25:39 2019//
+/shf.c/1.34/Sat Nov 2 03:25:39 2019//
+/shf.h/1.8/Sat Nov 2 03:25:39 2019//
+/syn.c/1.39/Sat Nov 2 03:25:39 2019//
+/table.c/1.25/Sat Nov 2 03:25:39 2019//
+/table.h/1.15/Sat Nov 2 03:25:39 2019//
+/trap.c/1.33/Sat Nov 2 03:25:39 2019//
+/tree.c/1.34/Sat Nov 2 03:25:39 2019//
+/tree.h/1.12/Sat Nov 2 03:25:39 2019//
+/tty.h/1.6/Sat Nov 2 03:25:39 2019//
+/version.c/1.12/Sat Nov 2 03:25:39 2019//
+/vi.c/1.56/Sat Nov 2 03:25:39 2019//
D
diff --git a/history.c b/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.82 2019/06/28 13:34:59 deraadt Exp $ */
+/* $OpenBSD: history.c,v 1.84 2019/10/27 15:02:19 jca Exp $ */
/*
* command history
@@ -13,7 +13,6 @@
*/
#include <sys/stat.h>
-#include <sys/uio.h>
#include <errno.h>
#include <fcntl.h>
@@ -559,6 +558,7 @@ void
sethistsize(int n)
{
if (n > 0 && (uint32_t)n != histsize) {
+ char **tmp;
int offset = histptr - history;
/* save most recent history */
@@ -571,10 +571,15 @@ sethistsize(int n)
memmove(history, histptr - offset, n * sizeof(char *));
}
- histsize = n;
- histbase = areallocarray(histbase, n + 1, sizeof(char *), APERM);
- history = histbase + 1;
- histptr = history + offset;
+ tmp = reallocarray(histbase, n + 1, sizeof(char *));
+ if (tmp != NULL) {
+ histbase = tmp;
+ histsize = n;
+ history = histbase + 1;
+ histptr = history + offset;
+ } else
+ warningf(false, "resizing history storage: %s",
+ strerror(errno));
}
}
@@ -618,8 +623,10 @@ init_histvec(void)
* allocate one extra element so that histptr always
* lies within array bounds
*/
- histbase = areallocarray(NULL, histsize + 1, sizeof(char *),
- APERM);
+ histbase = reallocarray(NULL, histsize + 1, sizeof(char *));
+ if (histbase == NULL)
+ internal_errorf("allocating history storage: %s",
+ strerror(errno));
*histbase = NULL;
history = histbase + 1;
histptr = history - 1;