diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-09-08 21:49:47 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-08 21:49:47 -0700 |
commit | da3b6f06e1224c9b8f5281a812731ef385ac4dc6 (patch) | |
tree | 75847482d3e90a71f07e30fff7e2dfd5239b3273 /builtin/unpack-objects.c | |
parent | Merge branch 'jk/format-patch-number-singleton-patch-with-cover' (diff) | |
parent | receive-pack: allow a maximum input size to be specified (diff) | |
download | tgif-da3b6f06e1224c9b8f5281a812731ef385ac4dc6.tar.xz |
Merge branch 'cc/receive-pack-limit'
An incoming "git push" that attempts to push too many bytes can now
be rejected by setting a new configuration variable at the receiving
end.
* cc/receive-pack-limit:
receive-pack: allow a maximum input size to be specified
unpack-objects: add --max-input-size=<size> option
index-pack: add --max-input-size=<size> option
Diffstat (limited to 'builtin/unpack-objects.c')
-rw-r--r-- | builtin/unpack-objects.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 172470bf24..4532aa0831 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -19,6 +19,7 @@ static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict] static unsigned char buffer[4096]; static unsigned int offset, len; static off_t consumed_bytes; +static off_t max_input_size; static git_SHA_CTX ctx; static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT; @@ -87,6 +88,8 @@ static void use(int bytes) if (signed_add_overflows(consumed_bytes, bytes)) die("pack too large for current definition of off_t"); consumed_bytes += bytes; + if (max_input_size && consumed_bytes > max_input_size) + die(_("pack exceeds maximum allowed size")); } static void *get_data(unsigned long size) @@ -550,6 +553,10 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix) len = sizeof(*hdr); continue; } + if (skip_prefix(arg, "--max-input-size=", &arg)) { + max_input_size = strtoumax(arg, NULL, 10); + continue; + } usage(unpack_usage); } |