svn commit: r298619 - head/sys/geom/uzip

Maxim Sobolev sobomax at FreeBSD.org
Tue Apr 26 06:50:39 UTC 2016


Author: sobomax
Date: Tue Apr 26 06:50:38 2016
New Revision: 298619
URL: https://svnweb.freebsd.org/changeset/base/298619

Log:
  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.

Modified:
  head/sys/geom/uzip/g_uzip.c

Modified: head/sys/geom/uzip/g_uzip.c
==============================================================================
--- head/sys/geom/uzip/g_uzip.c	Tue Apr 26 06:41:36 2016	(r298618)
+++ head/sys/geom/uzip/g_uzip.c	Tue Apr 26 06:50:38 2016	(r298619)
@@ -492,7 +492,7 @@ g_uzip_parse_toc(struct g_uzip_softc *sc
 	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 
 		    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));


More information about the svn-src-head mailing list