* [PATCH] fdisk: fix segfault on bsd label
@ 2012-05-04 11:35 Davidlohr Bueso
2012-05-04 13:53 ` Francesco Cosoleto
2012-05-10 9:46 ` Karel Zak
0 siblings, 2 replies; 5+ messages in thread
From: Davidlohr Bueso @ 2012-05-04 11:35 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
From: Davidlohr Bueso <dave@gnu.org>
Commit 8db8295d824cd0c8cba9385e4635d6e311d69d3f added a regression that causes the program to crash when
touching the partition structure (pte) for BSD/OSF labels. Since DOS has its own initialization function,
allow BSD labels to use it as well.
Steps to reproduce:
$> fdisk bsd.img (obtained from blkid regression test files)
Command (m for help): p
...
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Segmentation fault
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
As discussed, this is a temporary fix, a nicer way of initializing bsd structures will be implemented in the short future.
fdisk/fdisk.c | 2 ++
fdisk/fdiskdoslabel.c | 2 +-
fdisk/fdiskdoslabel.h | 1 +
3 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index acc84d1..dccaf27 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -763,6 +763,8 @@ static int get_boot(int try_only) {
return 0;
if (check_osf_label()) {
+ /* intialize partitions for BSD as well */
+ dos_init();
if (!valid_part_table_flag(MBRbuffer)) {
disklabel = OSF_LABEL;
return 0;
diff --git a/fdisk/fdiskdoslabel.c b/fdisk/fdiskdoslabel.c
index 6a9a044..b91702a 100644
--- a/fdisk/fdiskdoslabel.c
+++ b/fdisk/fdiskdoslabel.c
@@ -54,7 +54,7 @@ static void clear_partition(struct partition *p)
set_nr_sects(p,0);
}
-static void dos_init(void)
+void dos_init(void)
{
int i;
diff --git a/fdisk/fdiskdoslabel.h b/fdisk/fdiskdoslabel.h
index f5568df..1897b6c 100644
--- a/fdisk/fdiskdoslabel.h
+++ b/fdisk/fdiskdoslabel.h
@@ -48,5 +48,6 @@ extern void dos_set_mbr_id(void);
extern void dos_delete_partition(int i);
extern int check_dos_label(void);
extern int is_dos_partition(int t);
+extern void dos_init(void);
#endif
--
1.7.8.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] fdisk: fix segfault on bsd label
2012-05-04 11:35 [PATCH] fdisk: fix segfault on bsd label Davidlohr Bueso
@ 2012-05-04 13:53 ` Francesco Cosoleto
2012-05-04 17:08 ` Davidlohr Bueso
2012-05-10 9:46 ` Karel Zak
1 sibling, 1 reply; 5+ messages in thread
From: Francesco Cosoleto @ 2012-05-04 13:53 UTC (permalink / raw)
To: Davidlohr Bueso; +Cc: Karel Zak, util-linux
2012/5/4 Davidlohr Bueso <dave@gnu.org>:
> From: Davidlohr Bueso <dave@gnu.org>
>
> Commit 8db8295d824cd0c8cba9385e4635d6e311d69d3f added a regression that causes the program to crash when
> touching the partition structure (pte) for BSD/OSF labels. Since DOS has its own initialization function,
> allow BSD labels to use it as well.
>
> Steps to reproduce:
>
> $> fdisk bsd.img (obtained from blkid regression test files)
> Command (m for help): p
> ...
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0x00000000
>
> Segmentation fault
Thanks Davidlohr for pointing out that regression. Does it occurs with
the command to print the partition table when the drive has a BSD
label and hasn't a valid DOS label, and it has no partition? Fdisk
switches from BSD label to DOS label without initializing DOS
structures, right?
fdisk.c:
bsd_command_prompt();
/* If we return we may want to make an empty DOS label? */
disklabel = DOS_LABEL;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fdisk: fix segfault on bsd label
2012-05-04 13:53 ` Francesco Cosoleto
@ 2012-05-04 17:08 ` Davidlohr Bueso
2012-05-04 18:59 ` Karel Zak
0 siblings, 1 reply; 5+ messages in thread
From: Davidlohr Bueso @ 2012-05-04 17:08 UTC (permalink / raw)
To: Francesco Cosoleto; +Cc: Karel Zak, util-linux
On Fri, 2012-05-04 at 15:53 +0200, Francesco Cosoleto wrote:
> 2012/5/4 Davidlohr Bueso <dave@gnu.org>:
> > From: Davidlohr Bueso <dave@gnu.org>
> >
> > Commit 8db8295d824cd0c8cba9385e4635d6e311d69d3f added a regression that causes the program to crash when
> > touching the partition structure (pte) for BSD/OSF labels. Since DOS has its own initialization function,
> > allow BSD labels to use it as well.
> >
> > Steps to reproduce:
> >
> > $> fdisk bsd.img (obtained from blkid regression test files)
> > Command (m for help): p
> > ...
> > I/O size (minimum/optimal): 512 bytes / 512 bytes
> > Disk identifier: 0x00000000
> >
> > Segmentation fault
>
> Thanks Davidlohr for pointing out that regression. Does it occurs with
> the command to print the partition table when the drive has a BSD
> label and hasn't a valid DOS label, and it has no partition? Fdisk
> switches from BSD label to DOS label without initializing DOS
> structures, right?
>From my analysis, yes.
>
> fdisk.c:
> bsd_command_prompt();
> /* If we return we may want to make an empty DOS label? */
> disklabel = DOS_LABEL;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fdisk: fix segfault on bsd label
2012-05-04 17:08 ` Davidlohr Bueso
@ 2012-05-04 18:59 ` Karel Zak
0 siblings, 0 replies; 5+ messages in thread
From: Karel Zak @ 2012-05-04 18:59 UTC (permalink / raw)
To: Davidlohr Bueso; +Cc: Francesco Cosoleto, util-linux
On Fri, May 04, 2012 at 07:08:30PM +0200, Davidlohr Bueso wrote:
> On Fri, 2012-05-04 at 15:53 +0200, Francesco Cosoleto wrote:
> > 2012/5/4 Davidlohr Bueso <dave@gnu.org>:
> > > From: Davidlohr Bueso <dave@gnu.org>
> > >
> > > Commit 8db8295d824cd0c8cba9385e4635d6e311d69d3f added a regression that causes the program to crash when
> > > touching the partition structure (pte) for BSD/OSF labels. Since DOS has its own initialization function,
> > > allow BSD labels to use it as well.
> > >
> > > Steps to reproduce:
> > >
> > > $> fdisk bsd.img (obtained from blkid regression test files)
> > > Command (m for help): p
> > > ...
> > > I/O size (minimum/optimal): 512 bytes / 512 bytes
> > > Disk identifier: 0x00000000
> > >
> > > Segmentation fault
> >
> > Thanks Davidlohr for pointing out that regression. Does it occurs with
> > the command to print the partition table when the drive has a BSD
> > label and hasn't a valid DOS label, and it has no partition? Fdisk
> > switches from BSD label to DOS label without initializing DOS
> > structures, right?
>
> From my analysis, yes.
Just note that some labels are nested -- for example BSD, minix
unixware, ... are subtypes (nested partition tables) within DOS.
This parent->child relationship will be also necessary to support
in new fdisk API.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fdisk: fix segfault on bsd label
2012-05-04 11:35 [PATCH] fdisk: fix segfault on bsd label Davidlohr Bueso
2012-05-04 13:53 ` Francesco Cosoleto
@ 2012-05-10 9:46 ` Karel Zak
1 sibling, 0 replies; 5+ messages in thread
From: Karel Zak @ 2012-05-10 9:46 UTC (permalink / raw)
To: Davidlohr Bueso; +Cc: util-linux
On Fri, May 04, 2012 at 01:35:32PM +0200, Davidlohr Bueso wrote:
> fdisk/fdisk.c | 2 ++
> fdisk/fdiskdoslabel.c | 2 +-
> fdisk/fdiskdoslabel.h | 1 +
> 3 files changed, 4 insertions(+), 1 deletions(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-05-10 9:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-04 11:35 [PATCH] fdisk: fix segfault on bsd label Davidlohr Bueso
2012-05-04 13:53 ` Francesco Cosoleto
2012-05-04 17:08 ` Davidlohr Bueso
2012-05-04 18:59 ` Karel Zak
2012-05-10 9:46 ` Karel Zak
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.