[prev in list] [next in list] [prev in thread] [next in thread]
List: mandoc-source
Subject: mdocml: Reject non-printable characters found in the input stream even
From: schwarze () mdocml ! bsd ! lv
Date: 2013-05-30 3:52:59
Message-ID: 201305300352.r4U3qxLT016837 () krisdoz ! my ! domain
[Download RAW message or body]
Log Message:
-----------
Reject non-printable characters found in the input stream even when
preceded by a backslash; otherwise, the escape sequence would later
be identified as invalid and the non-printable character would be
passed through to the output backends, sometimes triggering assertions.
Reported by Mike Small <smallm at panix dot com> on the mdocml discuss list.
Modified Files:
--------------
mdocml:
read.c
Revision Data
-------------
Index: read.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -Lread.c -Lread.c -u -p -r1.34 -r1.35
--- read.c
+++ read.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -328,6 +328,15 @@ mparse_buf_r(struct mparse *curp, struct
break;
}
+ /*
+ * Make sure we have space for at least
+ * one backslash and one other character
+ * and the trailing NUL byte.
+ */
+
+ if (pos + 2 >= (int)ln.sz)
+ resize_buf(&ln, 256);
+
/*
* Warn about bogus characters. If you're using
* non-ASCII encoding, you're screwing your
@@ -344,8 +353,6 @@ mparse_buf_r(struct mparse *curp, struct
mandoc_msg(MANDOCERR_BADCHAR, curp,
curp->line, pos, NULL);
i++;
- if (pos >= (int)ln.sz)
- resize_buf(&ln, 256);
ln.buf[pos++] = '?';
continue;
}
@@ -353,8 +360,6 @@ mparse_buf_r(struct mparse *curp, struct
/* Trailing backslash = a plain char. */
if ('\\' != blk.buf[i] || i + 1 == (int)blk.sz) {
- if (pos >= (int)ln.sz)
- resize_buf(&ln, 256);
ln.buf[pos++] = blk.buf[i++];
continue;
}
@@ -396,10 +401,20 @@ mparse_buf_r(struct mparse *curp, struct
break;
}
- /* Some other escape sequence, copy & cont. */
+ /* Catch escaped bogus characters. */
- if (pos + 1 >= (int)ln.sz)
- resize_buf(&ln, 256);
+ c = (unsigned char) blk.buf[i+1];
+
+ if ( ! (isascii(c) &&
+ (isgraph(c) || isblank(c)))) {
+ mandoc_msg(MANDOCERR_BADCHAR, curp,
+ curp->line, pos, NULL);
+ i += 2;
+ ln.buf[pos++] = '?';
+ continue;
+ }
+
+ /* Some other escape sequence, copy & cont. */
ln.buf[pos++] = blk.buf[i++];
ln.buf[pos++] = blk.buf[i++];
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic