Page MenuHomeFreeBSD

D37313.diff
No OneTemporary

D37313.diff

diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c
--- a/sys/geom/label/g_label.c
+++ b/sys/geom/label/g_label.c
@@ -394,6 +394,10 @@
if (pp->acw > 0)
return (NULL);
+ /* Skip broken disks that don't set their sector size */
+ if (pp->sectorsize == 0)
+ return (NULL);
+
if (strcmp(pp->geom->class->name, mp->name) == 0)
return (NULL);
diff --git a/sys/geom/label/g_label_ext2fs.c b/sys/geom/label/g_label_ext2fs.c
--- a/sys/geom/label/g_label_ext2fs.c
+++ b/sys/geom/label/g_label_ext2fs.c
@@ -62,10 +62,11 @@
pp = cp->provider;
label[0] = '\0';
- if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0)
- return;
+ KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
if (pp->sectorsize < sizeof(*fs))
return;
+ if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0)
+ return;
fs = g_read_data(cp, EXT2FS_SB_OFFSET, pp->sectorsize, NULL);
if (fs == NULL)
diff --git a/sys/geom/label/g_label_iso9660.c b/sys/geom/label/g_label_iso9660.c
--- a/sys/geom/label/g_label_iso9660.c
+++ b/sys/geom/label/g_label_iso9660.c
@@ -52,10 +52,11 @@
pp = cp->provider;
label[0] = '\0';
- if ((ISO9660_OFFSET % pp->sectorsize) != 0)
- return;
+ KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
if (pp->sectorsize < 0x28 + VOLUME_LEN)
return;
+ if ((ISO9660_OFFSET % pp->sectorsize) != 0)
+ return;
sector = g_read_data(cp, ISO9660_OFFSET, pp->sectorsize, NULL);
if (sector == NULL)
return;
diff --git a/sys/geom/label/g_label_reiserfs.c b/sys/geom/label/g_label_reiserfs.c
--- a/sys/geom/label/g_label_reiserfs.c
+++ b/sys/geom/label/g_label_reiserfs.c
@@ -59,10 +59,11 @@
secsize = cp->provider->sectorsize;
- if ((offset % secsize) != 0)
- return (NULL);
+ KASSERT(secsize != 0, ("Tasting a disk with 0 sectorsize"));
if (secsize < sizeof(*fs))
return (NULL);
+ if ((offset % secsize) != 0)
+ return (NULL);
fs = g_read_data(cp, offset, secsize, NULL);
if (fs == NULL)
diff --git a/sys/geom/label/g_label_ufs.c b/sys/geom/label/g_label_ufs.c
--- a/sys/geom/label/g_label_ufs.c
+++ b/sys/geom/label/g_label_ufs.c
@@ -139,6 +139,7 @@
label[0] = '\0';
fs = NULL;
+ KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
if (SBLOCKSIZE % pp->sectorsize != 0 || ffs_sbget(cp, &fs, UFS_STDSB,
UFS_NOHASHFAIL | UFS_NOCSUM | UFS_NOMSG, M_GEOM, g_use_g_read_data)
!= 0) {

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 1:07 PM (20 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14698193
Default Alt Text
D37313.diff (2 KB)

Event Timeline