Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH] befs.c: validate di_br_size !=0 and br_per_di_br != 0
@ 2011-08-09  7:40 Timo Warns
  2011-08-15 12:34 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Timo Warns @ 2011-08-09  7:40 UTC (permalink / raw)
  To: util-linux

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;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-15 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09  7:40 [PATCH] befs.c: validate di_br_size !=0 and br_per_di_br != 0 Timo Warns
2011-08-15 12:34 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox