From c203e7c5b20f530e87917bd0986e9d274bdedaa0 Mon Sep 17 00:00:00 2001 From: tg Date: Mon, 7 Aug 2017 20:43:00 +0000 Subject: [PATCH] =?UTF-8?q?part=202:=20don=E2=80=99t=20stop=20using=20the?= =?UTF-8?q?=20history=20if=20the=20file=20has=20been=20truncated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- histrap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/histrap.c b/histrap.c index 4410b84..7d43c8a 100644 --- a/histrap.c +++ b/histrap.c @@ -27,7 +27,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.163 2017/08/07 20:40:57 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.164 2017/08/07 20:43:00 tg Exp $"); Trap sigtraps[ksh_NSIG + 1]; static struct sigaction Sigact_ign; @@ -963,10 +963,11 @@ writehistfile(int lno, const char *cmd) mksh_lockfd(histfd); sizenow = lseek(histfd, (off_t)0, SEEK_END); if (sizenow < histfsize) { - /* the file has shrunk; give up */ - goto bad; - } - if ( + /* the file has shrunk; trust it just appending the new data */ + /* well, for now, anyway… since mksh strdups all into memory */ + /* we can use a nicer approach some time later… */ + ; + } else if ( /* ignore changes when the file is too large */ sizenow <= MKSH_MAXHISTFSIZE &&