diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-12-18 17:43:41 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-12-18 17:43:41 +0000 |
commit | ed6fded4566ee185f6df132e01bdc959289d3836 (patch) | |
tree | 22821a0d7c565970f160555b19589a136985f474 | |
parent | 3fb7dda032c3ece1e7e2c94baf670de993e922f5 (diff) | |
download | mandoc-ed6fded4566ee185f6df132e01bdc959289d3836.tar.gz |
Don't let the modulo operator divide by zero.
Found by jsg@ with afl.
-rw-r--r-- | roff.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1576,7 +1576,7 @@ roff_evalnum(struct roff *r, int ln, const char *v, *res *= operand2; break; case '/': - if (0 == operand2) { + if (operand2 == 0) { mandoc_msg(MANDOCERR_DIVZERO, r->parse, ln, *pos, v); *res = 0; @@ -1585,6 +1585,12 @@ roff_evalnum(struct roff *r, int ln, const char *v, *res /= operand2; break; case '%': + if (operand2 == 0) { + mandoc_msg(MANDOCERR_DIVZERO, + r->parse, ln, *pos, v); + *res = 0; + break; + } *res %= operand2; break; case '<': |