From: "Ph. Marek" <philipp.marek@bmlv.gv.at>
To: aeb@cwi.nl
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] fs/partitions/msdos.c Guard against negative sizes
Date: Mon, 27 Jan 2003 12:30:05 +0100 [thread overview]
Message-ID: <200301271230.05814.philipp.marek@bmlv.gv.at> (raw)
Hello Andries,
I've recently had a partly destroyed pc where the partition size was negative.
I was at that time running a dos recovery disk and having severe problems -
it would not boot.
So I had the idea of looking into the linux kernel to see how it would handle
these. I wrote some checks in fs/partitions/msdos.c.
I'm not sure if just dropping this partitions is the right thing to do - but
as I don't know what could break if there are wrong entries I propose the
following patch: (incomplete - should check in many more places)
If there is a better way of handling this I'd like to know.
Regards,
Phil
diff -u linux-2.5.59/fs/partitions/msdos.c.orig
linux-2.5.59/fs/partitions/msdos.c
--- linux-2.5.59/fs/partitions/msdos.c.orig Mon Jan 27 12:22:45 2003
+++ linux-2.5.59/fs/partitions/msdos.c Mon Jan 27 12:24:28 2003
@@ -133,6 +133,8 @@
these sometimes contain random garbage */
offs = START_SECT(p)*sector_size;
size = NR_SECTS(p)*sector_size;
+ if (size<0)
+ continue;
next = this_sector + offs;
if (i >= 2) {
if (offs + size > this_size)
@@ -423,7 +425,7 @@
for (slot = 1 ; slot <= 4 ; slot++, p++) {
u32 start = START_SECT(p)*sector_size;
u32 size = NR_SECTS(p)*sector_size;
- if (!size)
+ if (size <= 0)
continue;
if (is_extended_partition(p)) {
/* prevent someone doing mkfs or mkswap on an
next reply other threads:[~2003-01-27 11:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-27 11:30 Ph. Marek [this message]
2003-01-27 14:03 ` Andries Brouwer
[not found] <UTC200301271203.h0RC3Sb19647.aeb@smtp.cwi.nl>
2003-01-27 15:38 ` Ph. Marek
2003-01-27 16:48 Andries.Brouwer
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=200301271230.05814.philipp.marek@bmlv.gv.at \
--to=philipp.marek@bmlv.gv.at \
--cc=aeb@cwi.nl \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®