summaryrefslogtreecommitdiff
path: root/isofs/main.c
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-04-17 16:36:32 +0200
committerJustus Winter <justus@gnupg.org>2016-04-17 17:08:26 +0200
commit21ee0e79e90c3cf63613bc1a00a609cfaf1777b2 (patch)
tree2bd6b7a1bbbd475f0a5a7065fe7b99ad6fd94281 /isofs/main.c
parent54ab56a23c472729ba3834f90b01c4406ed358b8 (diff)
isofs: make superblock detection more robust
* isofs/isofs.h (disk_image_len): New variable. * isofs/main.c (read_sblock): Avoid out of bounds access. * isofs/pager.c (disk_image_len): New variable. (create_disk_pager): Initialize 'disk_image_len'.
Diffstat (limited to 'isofs/main.c')
-rw-r--r--isofs/main.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/isofs/main.c b/isofs/main.c
index 95c90fe8..c07cf3ff 100644
--- a/isofs/main.c
+++ b/isofs/main.c
@@ -72,17 +72,13 @@ static void
read_sblock ()
{
struct voldesc *vd;
- error_t err;
struct sblock * volatile sb = 0;
- err = diskfs_catch_exception ();
- if (err)
- error (4, err, "reading superblock");
-
/* Start at logical sector 16 and keep going until
we find a matching superblock */
for (vd = disk_image + (logical_sector_size * 16);
- (void *) vd < disk_image + (logical_sector_size * 500); /* for sanity */
+ (void *) vd < disk_image + (logical_sector_size * 500) /* for sanity */
+ && (void *) vd + logical_sector_size < disk_image + disk_image_len;
vd = (void *) vd + logical_sector_size)
{
if (vd->type == VOLDESC_END)
@@ -105,7 +101,6 @@ read_sblock ()
if (!sblock)
error (1, errno, "Could not allocate memory for superblock");
memcpy (sblock, sb, sizeof (struct sblock));
- diskfs_end_catch_exception ();
/* Parse some important bits of this */
logical_block_size = isonum_723 (sblock->blksize);