diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-12 13:06:33 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-13 09:34:20 +0200 |
commit | 77b339f7b6c7e167ecaf9374eb6876b498d8cb83 (patch) | |
tree | 2067451017501f2d2411442370a71997c715e52b /src/odb.c | |
parent | f85a9c2767b43f35904bf39858488a4b7bc304e8 (diff) | |
download | libgit2-77b339f7b6c7e167ecaf9374eb6876b498d8cb83.tar.gz |
odb: make the writestream's size a git_off_tcmn/stream-size
Restricting files to size_t is a silly limitation. The loose backend
writes to a file directly, so there is no issue in using 63 bits for the
size.
We still assume that the header is going to fit in 64 bytes, which does
mean quite a bit smaller files due to the run-length encoding, but it's
still a much larger size than you would want Git to handle.
Diffstat (limited to 'src/odb.c')
-rw-r--r-- | src/odb.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -47,7 +47,7 @@ static git_cache *odb_cache(git_odb *odb) static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth); -int git_odb__format_object_header(char *hdr, size_t n, size_t obj_len, git_otype obj_type) +int git_odb__format_object_header(char *hdr, size_t n, git_off_t obj_len, git_otype obj_type) { const char *type_str = git_object_type2string(obj_type); int len = p_snprintf(hdr, n, "%s %"PRIuZ, type_str, obj_len); @@ -327,10 +327,15 @@ static void fake_wstream__free(git_odb_stream *_stream) git__free(stream); } -static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend, size_t size, git_otype type) +static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend, git_off_t size, git_otype type) { fake_wstream *stream; + if (!git__is_ssizet(size)) { + giterr_set(GITERR_ODB, "object size too large to keep in memory"); + return -1; + } + stream = git__calloc(1, sizeof(fake_wstream)); GITERR_CHECK_ALLOC(stream); @@ -937,7 +942,7 @@ int git_odb_write( return error; } -static void hash_header(git_hash_ctx *ctx, size_t size, git_otype type) +static void hash_header(git_hash_ctx *ctx, git_off_t size, git_otype type) { char header[64]; int hdrlen; @@ -947,7 +952,7 @@ static void hash_header(git_hash_ctx *ctx, size_t size, git_otype type) } int git_odb_open_wstream( - git_odb_stream **stream, git_odb *db, size_t size, git_otype type) + git_odb_stream **stream, git_odb *db, git_off_t size, git_otype type) { size_t i, writes = 0; int error = GIT_ERROR; |