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:
11
histrap.c
11
histrap.c
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user