From: Ingo Schwarze <schwarze@usta.de>
To: tech@mdocml.bsd.lv
Subject: Re: Division by zero
Date: Sun, 19 Oct 2014 23:38:47 +0200 [thread overview]
Message-ID: <20141019213847.GB27298@iris.usta.de> (raw)
In-Reply-To: <544426E3.9000009@bsd.lv>
Hi Kristaps,
Kristaps Dzonsons wrote on Sun, Oct 19, 2014 at 11:02:27PM +0200:
> Enclosed is a patch to handle roff.c's division by zero.
Good point.
> This was found (indirectly) when playing with mandoc's new support
> for inline equations.
>
> groff(1) seems to actually warn us when this happens--if we're to do
> the same, we'll need to pass the mparse function through to the
> offending function.
Makes sense to me. Perhaps just hand the struct roff down into
roff_evalcond, roff_evalnum, and roff_evalpar? That one is
already a usual argument for many functions, while struct mparse
is not.
I think the message should be an ERROR, not a WARNING, because it
can have arbitrarily severe consequences on formatting and content.
Two more nits: You say "x / 0 = x". Hum, maybe. But groff prefers
a different lie: "x / 0 = 0". And operator2 is int, not float.
So i think you need something like
case '/':
if (operand2 == 0) {
scream("WOLF!");
*res = 0;
} else
*res /= operand2;
break;
> By the way, upon an audit, I see that term_ps.c is vulnerable to
> division by zero if the "scale" parameter in termp_ps is zero.
> However, we don't ever seem to re-set that, so it's ok.
Seems true.
Yours,
Ingo
--
To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv
next prev parent reply other threads:[~2014-10-19 21:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-19 21:02 Kristaps Dzonsons
2014-10-19 21:38 ` Ingo Schwarze [this message]
2014-10-20 10:11 ` Kristaps Dzonsons
2014-10-20 13:09 ` Ingo Schwarze
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141019213847.GB27298@iris.usta.de \
--to=schwarze@usta.de \
--cc=tech@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).