From: Timo Warns <Warns@Pre-Sense.DE>
To: util-linux@vger.kernel.org
Subject: [PATCH] befs.c: validate di_br_size !=0 and br_per_di_br != 0
Date: Tue, 9 Aug 2011 09:40:47 +0200 [thread overview]
Message-ID: <20110809074046.GA4237@vermeer.pre-sense.de> (raw)
Validate that di_br_size !=0 and br_per_di_br != 0. If one of them is 0, a
division-by-zero error will be triggered.
Signed-off-by: Timo Warns <warns@pre-sense.de>
---
diff -u util-linux-2.20-rc1-a/libblkid/src/superblocks/befs.c util-linux-2.20-rc1-b/libblkid/src/superblocks/befs.c
--- util-linux-2.20-rc1-a/libblkid/src/superblocks/befs.c 2011-07-20 21:55:23.000000000 +0200
+++ util-linux-2.20-rc1-b/libblkid/src/superblocks/befs.c 2011-08-09 09:32:56.000000000 +0200
@@ -200,9 +200,16 @@
int64_t di_br_size, br_per_di_br, di_index, i_index;
start -= FS64_TO_CPU(ds->max_indirect_range, fs_le);
+
di_br_size = (int64_t) FS16_TO_CPU(ds->double_indirect.len,
fs_le) << FS32_TO_CPU(bs->block_shift, fs_le);
+ if (di_br_size == 0)
+ return NULL;
+
br_per_di_br = di_br_size / sizeof(struct block_run);
+ if (br_per_di_br == 0)
+ return NULL;
+
di_index = start / (br_per_di_br * di_br_size);
i_index = (start % (br_per_di_br * di_br_size)) / di_br_size;
start = (start % (br_per_di_br * di_br_size)) % di_br_size;
next reply other threads:[~2011-08-09 7:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-09 7:40 Timo Warns [this message]
2011-08-15 12:34 ` [PATCH] befs.c: validate di_br_size !=0 and br_per_di_br != 0 Karel Zak
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=20110809074046.GA4237@vermeer.pre-sense.de \
--to=warns@pre-sense.de \
--cc=util-linux@vger.kernel.org \
/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