mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-07 20:17:59 +00:00
Merge pull request #2447 from phkelley/pkt_assert
Fix assert when receiving uncommon sideband packet
This commit is contained in:
commit
16e7596d78
@ -435,6 +435,8 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
|
||||
git_map map;
|
||||
int error;
|
||||
|
||||
assert(data && size);
|
||||
|
||||
/* the offset needs to be at the beginning of the a page boundary */
|
||||
page_start = (offset / page_size) * page_size;
|
||||
page_offset = offset - page_start;
|
||||
@ -453,6 +455,9 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
|
||||
{
|
||||
git_off_t current_size = idx->pack->mwf.size;
|
||||
|
||||
if (!size)
|
||||
return 0;
|
||||
|
||||
/* add the extra space we need at the end */
|
||||
if (p_ftruncate(idx->pack->mwf.fd, current_size + size) < 0) {
|
||||
giterr_system_set(errno);
|
||||
|
@ -592,6 +592,8 @@ int git_smart__download_pack(
|
||||
}
|
||||
} else if (pkt->type == GIT_PKT_DATA) {
|
||||
git_pkt_data *p = (git_pkt_data *) pkt;
|
||||
|
||||
if (p->len)
|
||||
error = writepack->append(writepack, p->data, p->len, stats);
|
||||
} else if (pkt->type == GIT_PKT_FLUSH) {
|
||||
/* A flush indicates the end of the packfile */
|
||||
|
Loading…
Reference in New Issue
Block a user