summaryrefslogtreecommitdiff
path: root/t/t7815-grep-binary.sh
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-09-05 08:18:02 +0200
committerJunio C Hamano <gitster@pobox.com>2025-09-05 14:35:53 -0700
commit88a2dc68c8c9a2cf04c6d6d52e4ac3b26788e273 (patch)
tree85d150ee6f26a7054c36ac113672910c5e87ee32 /t/t7815-grep-binary.sh
parent7a57fb1a597eb2fa281c00cac94863ad0d7d7f6c (diff)
upload-pack: don't ACK non-commits repeatedly in protocol v2
When a client performs a fetch or clone they can optionally send "have" lines to tell the server which objects they already have available locally. These object IDs are stored by the server in an object array so that it can remember any objects it doesn't have to include in the pack sent to the client. While there isn't any reason to do so, clients are free to send the same "have" line repeatedly. git-upload-pack(1) already knows to handle this well: every commit it has seen via a "have" line gets marked with the `THEY_HAVE` flag, and if such a commit is seen repeatedly we know to not process it another time. This also has the effect that we only store the object ID once, only, in the `have_obj` array. There is an edge case though: if the client sends an object ID that does not refer to a commit we neither store nor check the `THEY_HAVE` flag. This means that we repeatedly store the same object ID in our `have_obj` array, with two consequences: - In protocol v2 we deduplicate ACKs for commits, but not for any other objects as we send ACKs for every object ID in the `have_obj` array. - The `have_obj` array can grow in size indefinitely with both protocols. The potentially-more-serious issue is the second one, as we basically have a way for an adversary to allocate arbitrarily large buffers now. Ultimately, this doesn't seem to be all that serious though: on my machine, the growth of that array is at around 4MB/s, and after roughly five minutes I was only at 1GB RSS. So this is concerning, but only mildly so. Fix this bug by storing the `THEY_HAVE` flag independent of the object type so that we don't store duplicate object IDs in `have_obj` anymore. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7815-grep-binary.sh')
0 files changed, 0 insertions, 0 deletions