summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2018-03-17 13:29:12 +0000
committerkrw <krw@openbsd.org>2018-03-17 13:29:12 +0000
commitbd3b24611906e1167a27399e055c857e464b501b (patch)
tree80179d77699bafdd35e45880f393549085f22988
parentMake FPU registers available in core dumps and through ptrace(2). (diff)
downloadwireguard-openbsd-bd3b24611906e1167a27399e055c857e464b501b.tar.xz
wireguard-openbsd-bd3b24611906e1167a27399e055c857e464b501b.zip
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@
-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();