summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-05-19 13:39:05 +0200
committerPatrick Steinhardt <ps@pks.im>2017-06-06 09:38:44 +0200
commit83e0392ceadb7e1d9db09a7f013e28759a666e89 (patch)
treea1ddaaafe0732deda4f8263f9c82faf79b887615
parent350d2c47bcbf9d9c09f2b65c9659f0c5c2d683b5 (diff)
downloadlibgit2-83e0392ceadb7e1d9db09a7f013e28759a666e89.tar.gz
index: also sanity check entry size with compressed entries
We have a check in place whether the index has enough data left for the required footer after reading an index entry, but this was only used for uncompressed entries. Move the check down a bit so that it is executed for both compressed and uncompressed index entries.
-rw-r--r--src/index.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/index.c b/src/index.c
index ed9f47839..bff5d7f73 100644
--- a/src/index.c
+++ b/src/index.c
@@ -2358,10 +2358,6 @@ static size_t read_entry(
}
entry_size = index_entry_size(path_length, 0, entry.flags);
-
- if (INDEX_FOOTER_SIZE + entry_size > buffer_size)
- return 0;
-
entry.path = (char *)path_ptr;
} else {
size_t varint_len;
@@ -2386,6 +2382,9 @@ static size_t read_entry(
entry.path = tmp_path;
}
+ if (INDEX_FOOTER_SIZE + entry_size > buffer_size)
+ return 0;
+
if (index_entry_dup(out, index, &entry) < 0) {
git__free(tmp_path);
return 0;