summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2017-12-10 17:25:00 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2017-12-20 16:08:04 +0000
commit3e6533ba12c1c567f91efe621bdd155ff801877c (patch)
treeb30161e03a265bcf082d21f7daf03d7260008e2b /src
parent8642feba7429ac2941a879a0870a84a83a3664cd (diff)
downloadlibgit2-3e6533ba12c1c567f91efe621bdd155ff801877c.tar.gz
odb_loose: reject objects that cannot fit in memory
Check the size of objects being read from the loose odb backend and reject those that would not fit in memory with an error message that reflects the actual problem, instead of error'ing later with an unintuitive error message regarding truncation or invalid hashes.
Diffstat (limited to 'src')
-rw-r--r--src/odb_loose.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 2294931b4..9900aae2a 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -156,6 +156,11 @@ static int parse_header(
size < 0)
goto on_error;
+ if ((uint64_t)size > SIZE_MAX) {
+ giterr_set(GITERR_OBJECT, "object is larger than available memory");
+ return -1;
+ }
+
out->size = size;
if (GIT_ADD_SIZET_OVERFLOW(out_len, i, 1))