diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-08-10 11:02:31 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-08-10 11:02:31 +0000 |
commit | 70d91166e243927bddfea69d42e2c7249751b582 (patch) | |
tree | 843130860f7ac885acab1ea4acc21cd3e7f7a79b /usr.bin/mandoc/term.c | |
parent | 9f3fd8c59c9de0d9ee54c914a48fd408d300b067 (diff) |
Fix assertion failures caused by whitespace inside \o'' (overstrike)
sequences that jsg@ found with afl(1):
* Avoid writing \t\b in term.c.
* Handle trailing \b in term_ps.c.
Diffstat (limited to 'usr.bin/mandoc/term.c')
-rw-r--r-- | usr.bin/mandoc/term.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c index 822872c3323..32fa1b67e7c 100644 --- a/usr.bin/mandoc/term.c +++ b/usr.bin/mandoc/term.c @@ -1,7 +1,7 @@ -/* $OpenBSD: term.c,v 1.117 2016/03/20 16:50:30 krw Exp $ */ +/* $OpenBSD: term.c,v 1.118 2016/08/10 11:02:30 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010-2016 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 @@ -502,7 +502,9 @@ term_word(struct termp *p, const char *word) } } /* Trim trailing backspace/blank pair. */ - if (p->col > 2 && p->buf[p->col - 1] == ' ') + if (p->col > 2 && + (p->buf[p->col - 1] == ' ' || + p->buf[p->col - 1] == '\t')) p->col -= 2; continue; default: @@ -566,7 +568,7 @@ encode1(struct termp *p, int c) p->fontq[p->fonti] : TERMFONT_NONE; if (p->flags & TERMP_BACKBEFORE) { - if (p->buf[p->col - 1] == ' ') + if (p->buf[p->col - 1] == ' ' || p->buf[p->col - 1] == '\t') p->col--; else p->buf[p->col++] = 8; |