summaryrefslogtreecommitdiff
path: root/usr.bin/less
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2018-03-17 13:29:13 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2018-03-17 13:29:13 +0000
commit6498191c5f667a660080fda007c0da68a38537fc (patch)
tree2ab26a5d71fa8bf414672d0b510373d8c662a5de /usr.bin/less
parentc8e11843c18e9abc43bb2f4c5a7208b36b54e99a (diff)
Fix use after free that caused the creation of a spurious file.
As guenther@ said "fix whatever led to the \337 x 16 crap". anton@ came up with the same diff. ok nicm@
Diffstat (limited to 'usr.bin/less')
-rw-r--r--usr.bin/less/ch.c1
-rw-r--r--usr.bin/less/optfunc.c3
2 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/less/ch.c b/usr.bin/less/ch.c
index 58f08d3deb1..6c4bae2df63 100644
--- a/usr.bin/less/ch.c
+++ b/usr.bin/less/ch.c
@@ -366,6 +366,7 @@ end_logfile(void)
}
close(logfile);
logfile = -1;
+ free(namelogfile);
namelogfile = NULL;
}
diff --git a/usr.bin/less/optfunc.c b/usr.bin/less/optfunc.c
index ddd3712320b..2c0b81f1401 100644
--- a/usr.bin/less/optfunc.c
+++ b/usr.bin/less/optfunc.c
@@ -71,7 +71,7 @@ opt_o(int type, char *s)
}
switch (type) {
case INIT:
- namelogfile = s;
+ namelogfile = estrdup(s);
break;
case TOGGLE:
if (ch_getflags() & CH_CANSEEK) {
@@ -83,6 +83,7 @@ opt_o(int type, char *s)
return;
}
s = skipsp(s);
+ free(namelogfile);
namelogfile = lglob(s);
use_logfile(namelogfile);
sync_logfile();