Date: Tue, 26 Apr 2016 06:50:38 +0000 (UTC) From: Maxim Sobolev <sobomax@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298619 - head/sys/geom/uzip Message-ID: <201604260650.u3Q6ocGh084910@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604260650.u3Q6ocGh084910>