plug a buffer underflow read we executed with *every* testsuite run and

*every* interactive shell session (history didn’t contain anything when
we tested for ignoredups)… first caught by the new code… d’uuuuuuuuuuh!
This commit is contained in:
tg 2016-02-24 01:45:59 +00:00
parent f0a042f070
commit e9fc158472
1 changed files with 4 additions and 2 deletions

View File

@ -27,7 +27,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.153 2016/01/21 18:24:40 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.154 2016/02/24 01:45:59 tg Exp $");
Trap sigtraps[ksh_NSIG + 1];
static struct sigaction Sigact_ign;
@ -658,7 +658,9 @@ histsave(int *lnp, const char *cmd, int svmode, bool ignoredups)
strndupx(c, cmd, ccp - cmd, APERM);
if (svmode != HIST_APPEND) {
if (ignoredups && !strcmp(c, *histptr)
if (ignoredups &&
histptr >= history &&
!strcmp(c, *histptr)
#if !defined(MKSH_SMALL) && HAVE_PERSISTENT_HISTORY
&& !histsync()
#endif