diff options
author | joerg <joerg@FreeBSD.org> | 1996-03-14 21:44:32 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1996-03-14 21:44:32 +0000 |
commit | 25dec96ec5f0da71ccf7d0d6a2f27a524f8a66f5 (patch) | |
tree | d7c4dee7c09c6180fb97a7f19e464fa43dbb3eac /sys/isofs | |
parent | 36dc90ccd84a554a2f30cad4f4506746f345cafe (diff) | |
download | FreeBSD-src-25dec96ec5f0da71ccf7d0d6a2f27a524f8a66f5.zip FreeBSD-src-25dec96ec5f0da71ccf7d0d6a2f27a524f8a66f5.tar.gz |
Provide a better handling of partially corrupted directory entries.
Submitted by: bde
Diffstat (limited to 'sys/isofs')
-rw-r--r-- | sys/isofs/cd9660/cd9660_vnops.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 367ab7e..5bf1751 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vnops.c 8.3 (Berkeley) 1/23/94 - * $Id: cd9660_vnops.c,v 1.22 1995/11/20 03:57:50 dyson Exp $ + * $Id: cd9660_vnops.c,v 1.23 1995/12/03 17:14:38 bde Exp $ */ #include <sys/param.h> @@ -558,6 +558,7 @@ cd9660_readdir(ap) int endsearch; struct iso_directory_record *ep; u_short elen; + int namlen; int reclen; int isoflags; struct iso_mnt *imp; @@ -619,8 +620,6 @@ cd9660_readdir(ap) (bp->b_un.b_addr + entryoffsetinblock); reclen = isonum_711 (ep->length); - isoflags = isonum_711(imp->iso_ftype == ISO_FTYPE_HIGH_SIERRA? - &ep->date[6]: ep->flags); if (reclen == 0) { /* skip to next block, if any */ idp->curroff = roundup (idp->curroff, @@ -640,22 +639,25 @@ cd9660_readdir(ap) break; } + namlen = isonum_711 (ep->name_len); + if (reclen < ISO_DIRECTORY_RECORD_SIZE + namlen) { + error = EINVAL; + /* illegal entry, stop */ + break; + } + /* XXX: be more intelligent if we can */ idp->current.d_type = DT_UNKNOWN; - idp->current.d_namlen = isonum_711 (ep->name_len); + idp->current.d_namlen = namlen; + isoflags = isonum_711(imp->iso_ftype == ISO_FTYPE_HIGH_SIERRA? + &ep->date[6]: ep->flags); if (isoflags & 2) isodirino(&idp->current.d_fileno,ep,imp); else idp->current.d_fileno = dbtob(bp->b_blkno) + idp->curroff; - if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) { - error = EINVAL; - /* illegal entry, stop */ - break; - } - idp->curroff += reclen; /* * |