diff options
author | pjd <pjd@FreeBSD.org> | 2005-08-23 18:55:38 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2005-08-23 18:55:38 +0000 |
commit | 2e01dfe9a96b7c649c8b2795334e1f1906e6a1a9 (patch) | |
tree | 19b6c2e3f0210fe91f65b2e98bd3435a91664248 /sys/geom/label | |
parent | 86aa9b6f54b5b93df6828e2e09b001e78ca4bb45 (diff) | |
download | FreeBSD-src-2e01dfe9a96b7c649c8b2795334e1f1906e6a1a9.zip FreeBSD-src-2e01dfe9a96b7c649c8b2795334e1f1906e6a1a9.tar.gz |
Verify if we can actually read the data at given offset.
Reported by: Martin <nakal@nurfuerspam.de>
Diffstat (limited to 'sys/geom/label')
-rw-r--r-- | sys/geom/label/g_label_ext2fs.c | 3 | ||||
-rw-r--r-- | sys/geom/label/g_label_reiserfs.c | 16 |
2 files changed, 13 insertions, 6 deletions
diff --git a/sys/geom/label/g_label_ext2fs.c b/sys/geom/label/g_label_ext2fs.c index 1825237..379785f 100644 --- a/sys/geom/label/g_label_ext2fs.c +++ b/sys/geom/label/g_label_ext2fs.c @@ -58,6 +58,9 @@ g_label_ext2fs_taste(struct g_consumer *cp, char *label, size_t size) pp = cp->provider; label[0] = '\0'; + if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0) + return; + fs = (e2sb_t *)g_read_data(cp, EXT2FS_SB_OFFSET, pp->sectorsize, NULL); if (fs == NULL) return; diff --git a/sys/geom/label/g_label_reiserfs.c b/sys/geom/label/g_label_reiserfs.c index 8ef1ec8..c2bee71 100644 --- a/sys/geom/label/g_label_reiserfs.c +++ b/sys/geom/label/g_label_reiserfs.c @@ -49,11 +49,17 @@ typedef struct resiserfs_sb { } reiserfs_sb_t; static reiserfs_sb_t * -g_label_reiserfs_read_super(struct g_consumer *cp, off_t offset, off_t len) +g_label_reiserfs_read_super(struct g_consumer *cp, off_t offset) { reiserfs_sb_t *fs; + u_int secsize; - fs = (reiserfs_sb_t *)g_read_data(cp, offset, len, NULL); + secsize = cp->provider->sectorsize; + + if ((offset % secsize) != 0) + return (NULL); + + fs = (reiserfs_sb_t *)g_read_data(cp, offset, secsize, NULL); if (fs == NULL) return (NULL); @@ -77,12 +83,10 @@ g_label_reiserfs_taste(struct g_consumer *cp, char *label, size_t size) label[0] = '\0'; /* Try old format */ - fs = g_label_reiserfs_read_super(cp, REISERFS_OLD_DISK_OFFSET, - pp->sectorsize); + fs = g_label_reiserfs_read_super(cp, REISERFS_OLD_DISK_OFFSET); if (fs == NULL) { /* Try new format */ - fs = g_label_reiserfs_read_super(cp, REISERFS_NEW_DISK_OFFSET, - pp->sectorsize); + fs = g_label_reiserfs_read_super(cp, REISERFS_NEW_DISK_OFFSET); } if (fs == NULL) return; |