From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 3fbbc5be; for ; Thu, 18 Dec 2014 12:43:41 -0500 (EST) Date: Thu, 18 Dec 2014 12:43:41 -0500 (EST) Message-Id: <7133746924964544295.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Don't let the modulo operator divide by zero. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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