* mdocml: Don't let the modulo operator divide by zero.
@ 2014-12-18 17:43 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-12-18 17:43 UTC (permalink / raw)
To: source
Log Message:
-----------
Don't let the modulo operator divide by zero.
Found by jsg@ with afl.
Modified Files:
--------------
mdocml:
roff.c
Revision Data
-------------
Index: roff.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.c,v
retrieving revision 1.243
retrieving revision 1.244
diff -Lroff.c -Lroff.c -u -p -r1.243 -r1.244
--- roff.c
+++ roff.c
@@ -1576,7 +1576,7 @@ roff_evalnum(struct roff *r, int ln, con
*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, con
*res /= operand2;
break;
case '%':
+ if (operand2 == 0) {
+ mandoc_msg(MANDOCERR_DIVZERO,
+ r->parse, ln, *pos, v);
+ *res = 0;
+ break;
+ }
*res %= operand2;
break;
case '<':
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-12-18 17:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 17:43 mdocml: Don't let the modulo operator divide by zero schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).