diff options
author | 2015-01-22 21:36:44 +0000 | |
---|---|---|
committer | 2015-01-22 21:36:44 +0000 | |
commit | 61ee90da9a84ff01066c2599fce1404df46931b9 (patch) | |
tree | 0480c8d36f8633d5ba95566258ca8ceb5e8371cc | |
parent | Fix logic botch causing warnings with Clang. Reported by dhill, matches (diff) | |
download | wireguard-openbsd-61ee90da9a84ff01066c2599fce1404df46931b9.tar.xz wireguard-openbsd-61ee90da9a84ff01066c2599fce1404df46931b9.zip |
Traditional roff(7) explicitly allows certain control characters
in the input stream (SOH, STX, ETX, ENQ, ACK, BEL, BS) for specific
purposes (leaders, backspace, delimiters, .tr), but making sure
these don't leak through to the output is tricky, so mark them as
unsupported for now.
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 16 |
2 files changed, 12 insertions, 9 deletions
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index fb255d083af..ec68dc5356c 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.126 2015/01/21 20:20:49 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.127 2015/01/22 21:36:44 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -145,7 +145,7 @@ enum mandocerr { /* related to document structure and macros */ MANDOCERR_FILE, /* cannot open file */ MANDOCERR_ROFFLOOP, /* input stack limit exceeded, infinite loop? */ - MANDOCERR_BADCHAR, /* skipping bad character: number */ + MANDOCERR_CHAR_BAD, /* skipping bad character: number */ MANDOCERR_MACRO, /* skipping unknown macro: macro */ MANDOCERR_REQ_INSEC, /* skipping insecure request: request */ MANDOCERR_IT_STRAY, /* skipping item outside list: It ... */ @@ -172,6 +172,7 @@ enum mandocerr { MANDOCERR_UNSUPP, /* ===== start of unsupported features ===== */ MANDOCERR_TOOLARGE, /* input too large */ + MANDOCERR_CHAR_UNSUPP, /* unsupported control character: number */ MANDOCERR_REQ_UNSUPP, /* unsupported roff request: request */ MANDOCERR_TBL, /* unsupported table syntax */ MANDOCERR_TBLOPT, /* unsupported table option */ diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 1ddd57fb0c3..79762f42e9e 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.88 2015/01/22 19:26:16 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.89 2015/01/22 21:36:44 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -210,6 +210,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "unsupported feature", "input too large", + "unsupported control character", "unsupported roff request", "unsupported table syntax", "unsupported table option", @@ -364,9 +365,8 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) if (c & 0x80) { if ( ! (curp->filenc && preconv_encode( &blk, &i, &ln, &pos, &curp->filenc))) { - mandoc_vmsg(MANDOCERR_BADCHAR, - curp, curp->line, pos, - "0x%x", c); + mandoc_vmsg(MANDOCERR_CHAR_BAD, curp, + curp->line, pos, "0x%x", c); ln.buf[pos++] = '?'; i++; } @@ -378,8 +378,10 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) */ if (c == 0x7f || (c < 0x20 && c != 0x09)) { - mandoc_vmsg(MANDOCERR_BADCHAR, curp, - curp->line, pos, "0x%x", c); + mandoc_vmsg(c == 0x00 || c == 0x04 || + c > 0x0a ? MANDOCERR_CHAR_BAD : + MANDOCERR_CHAR_UNSUPP, + curp, curp->line, pos, "0x%x", c); i++; ln.buf[pos++] = '?'; continue; @@ -435,7 +437,7 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) if ( ! (isascii(c) && (isgraph(c) || isblank(c)))) { - mandoc_vmsg(MANDOCERR_BADCHAR, curp, + mandoc_vmsg(MANDOCERR_CHAR_BAD, curp, curp->line, pos, "0x%x", c); i += 2; ln.buf[pos++] = '?'; |