diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-12-07 00:08:53 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-12-07 00:08:53 +0000 |
commit | 7dd7e9890d9671522a535999d40e0970f883cbbf (patch) | |
tree | cbc0ef5c09bbb3e71747e477fc98260daa5e41f3 /usr.bin/mandoc/roff.c | |
parent | 67de4b6243d14565beae59c8d441b6da38f7a4bd (diff) |
Complete the merge of bsd.lv version 1.10.7:
No more functional changes, just sync ordering, comments and white space.
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r-- | usr.bin/mandoc/roff.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index de161836d77..87c1ce1ae79 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.21 2010/11/28 19:35:33 schwarze Exp $ */ +/* $Id: roff.c,v 1.22 2010/12/07 00:08:52 schwarze Exp $ */ /* * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -633,6 +633,12 @@ roff_block(ROFF_ARGS) (*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL); return(ROFF_IGN); } + + /* + * Re-write `de1', since we don't really care about + * groff's strange compatibility mode, into `de'. + */ + if (ROFF_de1 == tok) tok = ROFF_de; if (ROFF_de == tok) @@ -640,8 +646,10 @@ roff_block(ROFF_ARGS) else (*r->msg)(MANDOCERR_REQUEST, r->data, ln, ppos, roffs[tok].name); + while ((*bufp)[pos] && ' ' != (*bufp)[pos]) pos++; + while (' ' == (*bufp)[pos]) (*bufp)[pos++] = '\0'; } @@ -653,14 +661,18 @@ roff_block(ROFF_ARGS) * with the same name, if there is one. New content will be * added from roff_block_text() in multiline mode. */ + if (ROFF_de == tok) roff_setstr(r, name, "", 0); if ('\0' == (*bufp)[pos]) return(ROFF_IGN); + /* If present, process the custom end-of-line marker. */ + sv = pos; - while ((*bufp)[pos] && ' ' != (*bufp)[pos] && + while ((*bufp)[pos] && + ' ' != (*bufp)[pos] && '\t' != (*bufp)[pos]) pos++; @@ -682,8 +694,7 @@ roff_block(ROFF_ARGS) r->last->end[(int)sz] = '\0'; if ((*bufp)[pos]) - if ( ! (*r->msg)(MANDOCERR_ARGSLOST, r->data, ln, pos, NULL)) - return(ROFF_ERR); + (*r->msg)(MANDOCERR_ARGSLOST, r->data, ln, pos, NULL); return(ROFF_IGN); } @@ -858,7 +869,6 @@ roff_evalcond(const char *v, int *pos) return(ROFFRULE_DENY); } - /* ARGSUSED */ static enum rofferr roff_line_ignore(ROFF_ARGS) @@ -867,7 +877,6 @@ roff_line_ignore(ROFF_ARGS) return(ROFF_IGN); } - /* ARGSUSED */ static enum rofferr roff_line_error(ROFF_ARGS) @@ -877,7 +886,6 @@ roff_line_error(ROFF_ARGS) return(ROFF_IGN); } - /* ARGSUSED */ static enum rofferr roff_cond(ROFF_ARGS) @@ -919,9 +927,8 @@ roff_cond(ROFF_ARGS) */ if ('\0' == (*bufp)[pos] && sv != pos) { - if ((*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL)) - return(ROFF_IGN); - return(ROFF_ERR); + (*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL); + return(ROFF_IGN); } roffnode_push(r, tok, NULL, ln, ppos); @@ -1054,7 +1061,6 @@ roff_nr(ROFF_ARGS) return(ROFF_IGN); } - /* ARGSUSED */ static enum rofferr roff_so(ROFF_ARGS) @@ -1063,6 +1069,13 @@ roff_so(ROFF_ARGS) (*r->msg)(MANDOCERR_SO, r->data, ln, ppos, NULL); + /* + * Handle `so'. Be EXTREMELY careful, as we shouldn't be + * opening anything that's not in our cwd or anything beneath + * it. Thus, explicitly disallow traversing up the file-system + * or using absolute paths. + */ + name = *bufp + pos; if ('/' == *name || strstr(name, "../") || strstr(name, "/..")) { (*r->msg)(MANDOCERR_SOPATH, r->data, ln, pos, NULL); @@ -1073,7 +1086,6 @@ roff_so(ROFF_ARGS) return(ROFF_SO); } - /* ARGSUSED */ static enum rofferr roff_userdef(ROFF_ARGS) |