summaryrefslogtreecommitdiffstats
path: root/read.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-22 19:26:50 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-22 19:26:50 +0000
commit8ea11845e15b1e0a37ac25a16594415dbf5f5455 (patch)
tree5f2b6a848fda4310ef2106738d20a802776f81e1 /read.c
parent63ebad0cb63118712dc755e31dbc94228f2aeb27 (diff)
downloadmandoc-8ea11845e15b1e0a37ac25a16594415dbf5f5455.tar.gz
Don't let a failing mparse_open() clobber the filename pointer;
fixes error message content and a use after free for .so with non-existent target when -Wall or -Tlint is given.
Diffstat (limited to 'read.c')
-rw-r--r--read.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/read.c b/read.c
index 42aaca7d..07e6ce50 100644
--- a/read.c
+++ b/read.c
@@ -307,6 +307,7 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
{
const struct tbl_span *span;
struct buf ln;
+ const char *save_file;
char *cp;
size_t pos; /* byte number in the ln buffer */
enum rofferr rr;
@@ -522,11 +523,14 @@ rerun:
*/
if (curp->secondary)
curp->secondary->sz -= pos + 1;
+ save_file = curp->file;
save_child = curp->child;
if (mparse_open(curp, &fd, ln.buf + of) ==
- MANDOCLEVEL_OK)
+ MANDOCLEVEL_OK) {
mparse_readfd(curp, fd, ln.buf + of);
- else {
+ curp->file = save_file;
+ } else {
+ curp->file = save_file;
mandoc_vmsg(MANDOCERR_SO_FAIL,
curp, curp->line, pos,
".so %s", ln.buf + of);