source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Don't let a failing mparse_open() clobber the filename pointer;
@ 2015-01-22 19:27 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-01-22 19:27 UTC (permalink / raw)
  To: source

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        read.c

Revision Data
-------------
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -Lread.c -Lread.c -u -p -r1.112 -r1.113
--- read.c
+++ read.c
@@ -307,6 +307,7 @@ mparse_buf_r(struct mparse *curp, struct
 {
 	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);
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-22 19:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-22 19:27 mdocml: Don't let a failing mparse_open() clobber the filename pointer; schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).