commit 046f76c30e642757d0d52b64eabd263c7c206fec from: Stefan Sperling via: Thomas Adam date: Wed Mar 08 09:24:33 2023 UTC fix gotd sometimes reading reused deltas from wrong pack file The reuse-pack is pinned but may change its cache slot while objects are being deltified. Refresh the pointer to the pinned reuse-pack before writing out the pack file, ensuring that reused deltas will in fact be read from the reuse-pack and not some other pack. Otherwise gotd may send a broken pack file, or hit an ERR_RANGE condition if the pack file which now occupies the pinned-pack's old cache slot is shorter. Which can trigger attempts to read beyond end-of-file which show up in the logs like this: gotd[37311]: repo_read /var/git/got.git: sending packfile: value out of range gotd[43877]: uid 1002: value out of range gotd[43877]: uid 1002: disconnecting commit - 99fe3033f2c5c27a510a69c329fb1a542c4620cf commit + 046f76c30e642757d0d52b64eabd263c7c206fec blob - ae96825b2544aed0b77b6b83a68e89e97d24c0f1 blob + 7f48facde10d3f583396ed2c3e933d910b8ab006 --- lib/pack_create.c +++ lib/pack_create.c @@ -1932,6 +1932,9 @@ got_pack_create(uint8_t *packsha1, int packfd, FILE *d goto done; } + /* Pinned pack may have moved to different cache slot. */ + reuse_pack = got_repo_get_pinned_pack(repo); + err = genpack(packsha1, packfd, reuse_pack, delta_cache, deltify.meta, deltify.nmeta, reuse.meta, reuse.nmeta, ncolored, nfound, ntrees, nours, repo, force_refdelta, progress_cb, progress_arg, rl,