diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-20 13:56:20 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-20 13:56:20 +0000 |
commit | b300a4ff9ca15ee75ac8b05afd9d5817390384ae (patch) | |
tree | 4f00a927805ad8f4235e0cfd84d45384d664aae2 /term_ps.c | |
parent | f6678df24821d82cd83677550831b7542c29a741 (diff) | |
download | mandoc-b300a4ff9ca15ee75ac8b05afd9d5817390384ae.tar.gz mandoc-b300a4ff9ca15ee75ac8b05afd9d5817390384ae.tar.zst mandoc-b300a4ff9ca15ee75ac8b05afd9d5817390384ae.zip |
Prevent negative arguments to the .ll request from causing integer
underflow. Found while preparing an audit of termp.rmargin.
Overflow can also happen, but i see no sane way to deal with it,
so just let it happen. It doesn't happen for any sane input anyway,
groff behaviour is undefined, and the resulting values are legal,
even though they are useless.
Diffstat (limited to 'term_ps.c')
-rw-r--r-- | term_ps.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $Id: term_ps.c,v 1.68 2014/10/28 17:36:19 schwarze Exp $ */ +/* $Id: term_ps.c,v 1.69 2014/11/20 13:56:20 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -635,12 +635,14 @@ ps_setwidth(struct termp *p, int iop, size_t width) size_t lastwidth; lastwidth = p->ps->width; - if (0 < iop) + if (iop > 0) p->ps->width += width; - else if (0 > iop) + else if (iop == 0) + p->ps->width = width ? width : p->ps->lastwidth; + else if (p->ps->width > width) p->ps->width -= width; else - p->ps->width = width ? width : p->ps->lastwidth; + p->ps->width = 0; p->ps->lastwidth = lastwidth; } |