version 1.289, 2017/02/17 03:03:03 |
version 1.293, 2017/03/09 15:29:35 |
Line 1236 deroff(char **dest, const struct roff_node *n) |
|
Line 1236 deroff(char **dest, const struct roff_node *n) |
|
/* Skip trailing backslash. */ |
/* Skip trailing backslash. */ |
|
|
sz = strlen(cp); |
sz = strlen(cp); |
if (cp[sz - 1] == '\\') |
if (sz > 0 && cp[sz - 1] == '\\') |
sz--; |
sz--; |
|
|
/* Skip trailing whitespace. */ |
/* Skip trailing whitespace. */ |
Line 1608 roff_parseln(struct roff *r, int ln, struct buf *buf, |
|
Line 1608 roff_parseln(struct roff *r, int ln, struct buf *buf, |
|
return ROFF_IGN; |
return ROFF_IGN; |
while (buf->buf[pos] != '\0' && buf->buf[pos] != ' ') |
while (buf->buf[pos] != '\0' && buf->buf[pos] != ' ') |
pos++; |
pos++; |
while (buf->buf[pos] != '\0' && buf->buf[pos] == ' ') |
while (buf->buf[pos] == ' ') |
pos++; |
pos++; |
return tbl_read(r->tbl, ln, buf->buf, pos); |
return tbl_read(r->tbl, ln, buf->buf, pos); |
} |
} |
Line 3038 roff_userdef(ROFF_ARGS) |
|
Line 3038 roff_userdef(ROFF_ARGS) |
|
{ |
{ |
const char *arg[9], *ap; |
const char *arg[9], *ap; |
char *cp, *n1, *n2; |
char *cp, *n1, *n2; |
int i, ib, ie; |
int expand_count, i, ib, ie; |
size_t asz, rsz; |
size_t asz, rsz; |
|
|
/* |
/* |
Line 3062 roff_userdef(ROFF_ARGS) |
|
Line 3062 roff_userdef(ROFF_ARGS) |
|
*/ |
*/ |
|
|
buf->sz = strlen(r->current_string) + 1; |
buf->sz = strlen(r->current_string) + 1; |
n1 = cp = mandoc_malloc(buf->sz); |
n1 = n2 = cp = mandoc_malloc(buf->sz); |
memcpy(n1, r->current_string, buf->sz); |
memcpy(n1, r->current_string, buf->sz); |
|
expand_count = 0; |
while (*cp != '\0') { |
while (*cp != '\0') { |
|
|
/* Scan ahead for the next argument invocation. */ |
/* Scan ahead for the next argument invocation. */ |
Line 3081 roff_userdef(ROFF_ARGS) |
|
Line 3082 roff_userdef(ROFF_ARGS) |
|
continue; |
continue; |
} |
} |
cp -= 2; |
cp -= 2; |
|
|
|
/* |
|
* Prevent infinite recursion. |
|
*/ |
|
|
|
if (cp >= n2) |
|
expand_count = 1; |
|
else if (++expand_count > EXPAND_LIMIT) { |
|
mandoc_msg(MANDOCERR_ROFFLOOP, r->parse, |
|
ln, (int)(cp - n1), NULL); |
|
free(buf->buf); |
|
buf->buf = n1; |
|
return ROFF_IGN; |
|
} |
|
|
/* |
/* |
* Determine the size of the expanded argument, |
* Determine the size of the expanded argument, |