From: Jeff King Date: Fri, 13 Nov 2020 22:11:11 GMT Subject: Re: [PATCH 03/23] pack-bitmap: bounds-check size of cache extension Message-ID: <20201113221111.GA783373@coredump.intra.peff.net> In-Reply-To: On Fri, Nov 13, 2020 at 04:49:28PM -0500, Taylor Blau wrote: > Thanks for your patient explanation. This hunk should instead read: > > + size_t header_size = sizeof(*header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz; > > - if (index->map_size < sizeof(*header) + the_hash_algo->rawsz) > + if (index->map_size < header_size + the_hash_algo->rawsz) > return error("Corrupted bitmap index (missing header data)"); > > That error might not necessarily be right (it could say "missing header > or trailer data"), though. I'm open to if you think it should be > changed or not. Yeah, I agree it's misleading. In the idx code path we just say "%s is too small", which is more accurate. -Peff