summaryrefslogtreecommitdiffstats
path: root/sys/geom/uzip
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2016-04-26 06:50:38 +0000
committersobomax <sobomax@FreeBSD.org>2016-04-26 06:50:38 +0000
commitbaab3f7672beb50da843ff40681c17d9a41c5164 (patch)
treef40bd8d0af3db061d75d9e84a7126b0d00a64abb /sys/geom/uzip
parent493d8c5c487c2bf4a0f7726c6ec7b10bd63e13a6 (diff)
downloadFreeBSD-src-baab3f7672beb50da843ff40681c17d9a41c5164.zip
FreeBSD-src-baab3f7672beb50da843ff40681c17d9a41c5164.tar.gz
Relax TOC offsets checking somewhat, allowing offset pointing to
the next byte past EOF to denote zero-block(s) at the very end of the file.
Diffstat (limited to 'sys/geom/uzip')
-rw-r--r--sys/geom/uzip/g_uzip.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/geom/uzip/g_uzip.c b/sys/geom/uzip/g_uzip.c
index 97388fa..768a454 100644
--- a/sys/geom/uzip/g_uzip.c
+++ b/sys/geom/uzip/g_uzip.c
@@ -492,7 +492,7 @@ g_uzip_parse_toc(struct g_uzip_softc *sc, struct g_provider *pp,
for (i = 0; i < sc->nblocks; i++) {
/* First do some bounds checking */
if ((sc->toc[i].offset < min_offset) ||
- (sc->toc[i].offset >= pp->mediasize)) {
+ (sc->toc[i].offset > pp->mediasize)) {
goto error_offset;
}
DPRINTF_BLK(GUZ_DBG_IO, i, ("%s: cluster #%u "
@@ -711,6 +711,11 @@ g_uzip_taste(struct g_class *mp, struct g_provider *pp, int flags)
sc->nblocks < offsets_read ? "more" : "less"));
goto e5;
}
+ /*
+ * "Fake" last+1 block, to make it easier for the TOC parser to
+ * iterate without making the last element a special case.
+ */
+ sc->toc[sc->nblocks].offset = pp->mediasize;
/* Massage TOC (table of contents), make sure it is sound */
if (g_uzip_parse_toc(sc, pp, gp) != 0) {
DPRINTF(GUZ_DBG_ERR, ("%s: TOC error\n", gp->name));
OpenPOWER on IntegriCloud