All of lore.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Otto Visser <work@otvi.nl>
Cc: util-linux@vger.kernel.org
Subject: Re: [libfdisk] incorrect GPT header leads to segfault
Date: Mon, 23 Mar 2015 12:16:40 +0100	[thread overview]
Message-ID: <20150323111640.GE1749@ws.net.home> (raw)
In-Reply-To: <550C1E49.3000509@otvi.nl>

On Fri, Mar 20, 2015 at 02:19:05PM +0100, Otto Visser wrote:
> I then made the following (ordering) change in libfdisk/src/gpt.c:
> 
> 956a957,961
> >       /* make sure header size is between 92 and sector size bytes */
> >       hsz = le32_to_cpu(header->size);
> >       if (hsz < GPT_HEADER_MINSZ || hsz > cxt->sector_size)
> >               goto invalid;
> >
> 973,977d977
> <               goto invalid;
> <
> <       /* make sure header size is between 92 and sector size bytes */
> <       hsz = le32_to_cpu(header->size);
> <       if (hsz < GPT_HEADER_MINSZ || hsz > cxt->sector_size)

Thanks. Fixed.

> Although this fixes getting the segfault, it still means that fdisk
> concludes there is no GPT label, despite that the signature is clearly
> there; hence I wouldn't want to call this an actual patch.

Well, be able to work with broken GPT header means that we have to
implement something like fsck for GPT -- analyze each field in the
header and try to fix it. I'm going to add this to TODO.

I don't think something like GPT fsck should be within regular GPT
probing code. It's very special use-case.

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

      reply	other threads:[~2015-03-23 11:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 13:19 [libfdisk] incorrect GPT header leads to segfault Otto Visser
2015-03-23 11:16 ` Karel Zak [this message]

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=20150323111640.GE1749@ws.net.home \
    --to=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    --cc=work@otvi.nl \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.