=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/read.c,v retrieving revision 1.168 retrieving revision 1.169 diff -c -r1.168 -r1.169 *** src/usr.bin/mandoc/read.c 2018/07/28 18:32:30 1.168 --- src/usr.bin/mandoc/read.c 2018/08/23 14:16:12 1.169 *************** *** 1,4 **** ! /* $OpenBSD: read.c,v 1.168 2018/07/28 18:32:30 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2018 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: read.c,v 1.169 2018/08/23 14:16:12 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2018 Ingo Schwarze *************** *** 60,66 **** static void choose_parser(struct mparse *); static void resize_buf(struct buf *, size_t); ! static int mparse_buf_r(struct mparse *, struct buf, size_t, int); static int read_whole_file(struct mparse *, const char *, int, struct buf *, int *); static void mparse_end(struct mparse *); --- 60,66 ---- static void choose_parser(struct mparse *); static void resize_buf(struct buf *, size_t); ! static enum rofferr mparse_buf_r(struct mparse *, struct buf, size_t, int); static int read_whole_file(struct mparse *, const char *, int, struct buf *, int *); static void mparse_end(struct mparse *); *************** *** 231,236 **** --- 231,237 ---- "input stack limit exceeded, infinite loop?", "skipping bad character", "skipping unknown macro", + "ignoring request outside macro", "skipping insecure request", "skipping item outside list", "skipping column outside column list", *************** *** 241,246 **** --- 242,249 ---- /* related to request and macro arguments */ "escaped character not allowed in a name", + "using macro argument outside macro", + "argument number is not numeric", "NOT IMPLEMENTED: Bd -file", "skipping display without arguments", "missing list type, using -item", *************** *** 249,254 **** --- 252,258 ---- "uname(3) system call failed, using UNKNOWN", "unknown standard specifier", "skipping request without numeric argument", + "excessive shift", "NOT IMPLEMENTED: .so with absolute path or \"..\"", ".so request failed", "skipping all arguments", *************** *** 336,349 **** * macros, inline equations, and input line traps) * and indirectly (for .so file inclusion). */ ! static int mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) { struct buf ln; const char *save_file; char *cp; size_t pos; /* byte number in the ln buffer */ ! enum rofferr rr; int of; int lnn; /* line number in the real file */ int fd; --- 340,353 ---- * macros, inline equations, and input line traps) * and indirectly (for .so file inclusion). */ ! static enum rofferr mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) { struct buf ln; const char *save_file; char *cp; size_t pos; /* byte number in the ln buffer */ ! enum rofferr line_result, sub_result; int of; int lnn; /* line number in the real file */ int fd; *************** *** 466,485 **** [curp->secondary->sz] = '\0'; } rerun: ! rr = roff_parseln(curp->roff, curp->line, &ln, &of); ! switch (rr) { case ROFF_REPARSE: ! if (++curp->reparse_count > REPARSE_LIMIT) mandoc_msg(MANDOCERR_ROFFLOOP, curp, curp->line, pos, NULL); ! else if (mparse_buf_r(curp, ln, of, 0) == 1 || ! start == 1) { pos = 0; continue; } free(ln.buf); ! return 0; case ROFF_APPEND: pos = strlen(ln.buf); continue; --- 470,505 ---- [curp->secondary->sz] = '\0'; } rerun: ! line_result = roff_parseln(curp->roff, curp->line, &ln, &of); ! switch (line_result) { case ROFF_REPARSE: ! case ROFF_USERCALL: ! if (++curp->reparse_count > REPARSE_LIMIT) { ! sub_result = ROFF_IGN; mandoc_msg(MANDOCERR_ROFFLOOP, curp, curp->line, pos, NULL); ! } else { ! sub_result = mparse_buf_r(curp, ln, of, 0); ! if (line_result == ROFF_USERCALL) { ! if (sub_result == ROFF_USERRET) ! sub_result = ROFF_CONT; ! roff_userret(curp->roff); ! } ! if (start || sub_result == ROFF_CONT) { ! pos = 0; ! continue; ! } ! } ! free(ln.buf); ! return sub_result; ! case ROFF_USERRET: ! if (start) { pos = 0; continue; } free(ln.buf); ! return ROFF_USERRET; case ROFF_APPEND: pos = strlen(ln.buf); continue; *************** *** 493,499 **** (i >= blk.sz || blk.buf[i] == '\0')) { curp->sodest = mandoc_strdup(ln.buf + of); free(ln.buf); ! return 1; } /* * We remove `so' clauses from our lookaside --- 513,519 ---- (i >= blk.sz || blk.buf[i] == '\0')) { curp->sodest = mandoc_strdup(ln.buf + of); free(ln.buf); ! return ROFF_CONT; } /* * We remove `so' clauses from our lookaside *************** *** 545,551 **** } free(ln.buf); ! return 1; } static int --- 565,571 ---- } free(ln.buf); ! return ROFF_CONT; } static int