mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 08:11:58 +00:00
Merge pull request #3559 from yongthecoder/master
Add a sanity check in git_indexer_commit to avoid subtraction overflow.
This commit is contained in:
commit
e50a49ee9b
@ -914,12 +914,17 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
|
|||||||
git_filebuf index_file = {0};
|
git_filebuf index_file = {0};
|
||||||
void *packfile_trailer;
|
void *packfile_trailer;
|
||||||
|
|
||||||
|
if (!idx->parsed_header) {
|
||||||
|
giterr_set(GITERR_INDEXER, "incomplete pack header");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (git_hash_ctx_init(&ctx) < 0)
|
if (git_hash_ctx_init(&ctx) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Test for this before resolve_deltas(), as it plays with idx->off */
|
/* Test for this before resolve_deltas(), as it plays with idx->off */
|
||||||
if (idx->off < idx->pack->mwf.size - 20) {
|
if (idx->off + 20 < idx->pack->mwf.size) {
|
||||||
giterr_set(GITERR_INDEXER, "Unexpected data at the end of the pack");
|
giterr_set(GITERR_INDEXER, "unexpected data at the end of the pack");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user