From: Kristaps Dzonsons <kristaps@bsd.lv>
To: tech@mdocml.bsd.lv
Subject: Division by zero
Date: Sun, 19 Oct 2014 23:02:27 +0200 [thread overview]
Message-ID: <544426E3.9000009@bsd.lv> (raw)
[-- Attachment #1: Type: text/plain, Size: 514 bytes --]
Hi,
Enclosed is a patch to handle roff.c's division by zero. 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.
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.
Best,
Kristaps
[-- Attachment #2: divbyzero.patch --]
[-- Type: text/plain, Size: 1172 bytes --]
? .DS_Store
? .test.1.swp
? Makefile.local
? TEST.sh
? TEST.sh.out
? bar.1
? cgi-doc.diff
? cgi.h
? config.h
? config.log
? configure.local
? demandoc
? ditto.1
? divbyzero.patch
? eqn-test.1
? eqn-test.1.html
? eqn.2.patch
? eqn.bak.c
? eqn.patch
? foo
? foo.1
? foo.1.html
? foo.1.ps
? foo.2
? foo.2.html
? foo.3
? foo.3.html
? foo.4
? foo.4.html
? foo.5
? foo.5.html
? foo.5.ps
? foo.sh
? makewhatis
? man.cgi
? mandoc
? plockstat.1
? preconv
? term.diff
? test-dirent-namlen.dSYM
? test-fgetln.dSYM
? test-fts.dSYM
? test-getsubopt.dSYM
? test-mmap.dSYM
? test-sqlite3.dSYM
? test-strcasestr.dSYM
? test-strlcat.dSYM
? test-strlcpy.dSYM
? test-strptime.dSYM
? test-strsep.dSYM
? test-wchar.dSYM
? test.1
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.231
diff -u -p -r1.231 roff.c
--- roff.c 16 Oct 2014 01:28:38 -0000 1.231
+++ roff.c 19 Oct 2014 20:54:47 -0000
@@ -1545,6 +1545,8 @@ roff_evalnum(const char *v, int *pos, in
*res *= operand2;
break;
case '/':
+ if (0.0 == operand2)
+ break;
*res /= operand2;
break;
case '%':
next reply other threads:[~2014-10-19 21:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-19 21:02 Kristaps Dzonsons [this message]
2014-10-19 21:38 ` Ingo Schwarze
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=544426E3.9000009@bsd.lv \
--to=kristaps@bsd.lv \
--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).