SECURITY: make “unset HISTFILE” really work

additionally, make “HISTFILE=” the same, document the truncation and
re-reading process’ further and already-known bugs; this needs work
This commit is contained in:
tg
2015-03-07 20:46:31 +00:00
parent d3f3c3ec22
commit be147e3426
5 changed files with 36 additions and 15 deletions

View File

@@ -27,7 +27,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.139 2015/02/06 10:09:06 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.140 2015/03/07 20:46:28 tg Exp $");
Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign;
@@ -563,7 +563,7 @@ sethistfile(const char *name)
return;
/* if the name is the same as the name we have */
if (hname && strcmp(hname, name) == 0)
if (hname && name && !strcmp(hname, name))
return;
/*
@@ -581,7 +581,8 @@ sethistfile(const char *name)
hist_source->line = 0;
}
hist_init(hist_source);
if (name)
hist_init(hist_source);
}
#endif
@@ -712,8 +713,10 @@ hist_init(Source *s)
hist_source = s;
#if HAVE_PERSISTENT_HISTORY
if ((hname = str_val(global("HISTFILE"))) == NULL)
if (((hname = str_val(global("HISTFILE"))) == NULL) || !*hname) {
hname = NULL;
return;
}
strdupx(hname, hname, APERM);
hs = hist_init_first;