]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/upload-archive.c
upload-archive: use argv_array to store client arguments
authorJeff King <peff@peff.net>
Wed, 20 Feb 2013 20:01:26 +0000 (15:01 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Feb 2013 21:42:21 +0000 (13:42 -0800)
commit090fd4fe24b9da9d912aa5856f4cd32d157924c6
tree38bfc3c1f2b987b25fcb302721af7f2393673ebf
parent6379dd052243aa6b1cc5115b72b78aedbeeed008
upload-archive: use argv_array to store client arguments

The current parsing scheme for upload-archive is to pack
arguments into a fixed-size buffer, separated by NULs, and
put a pointer to each argument in the buffer into a
fixed-size argv array.

This works fine, and the limits are high enough that nobody
reasonable is going to hit them, but it makes the code hard
to follow.  Instead, let's just stuff the arguments into an
argv_array, which is much simpler. That lifts the "all
arguments must fit inside 4K together" limit.

We could also trivially lift the MAX_ARGS limitation (in
fact, we have to keep extra code to enforce it). But that
would mean a client could force us to allocate an arbitrary
amount of memory simply by sending us "argument" lines. By
limiting the MAX_ARGS, we limit an attacker to about 4
megabytes (64 times a maximum 64K packet buffer). That may
sound like a lot compared to the 4K limit, but it's not a
big deal compared to what git-archive will actually allocate
while working (e.g., to load blobs into memory). The
important thing is that it is bounded.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/upload-archive.c