diff options
author | Vicent Marti <vicent@github.com> | 2014-06-27 18:11:06 +0200 |
---|---|---|
committer | Vicent Marti <vicent@github.com> | 2014-06-27 18:11:06 +0200 |
commit | 16e7596d78ff233c6f1aa42678fde8b946b44f4b (patch) | |
tree | 5f0f954c793fcb664d52b0c5cea490d50b6dd360 | |
parent | 0145afe635b57bfbc3950030a572187b0644c0c5 (diff) | |
parent | bc8a0886853c17d0899e9148d5c11c2c231c3ab4 (diff) | |
download | libgit2-16e7596d78ff233c6f1aa42678fde8b946b44f4b.tar.gz |
Merge pull request #2447 from phkelley/pkt_assert
Fix assert when receiving uncommon sideband packet
-rw-r--r-- | src/indexer.c | 5 | ||||
-rw-r--r-- | src/transports/smart_protocol.c | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/indexer.c b/src/indexer.c index eb8b23e92..8daff3dc4 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -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); diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c index a52aacc60..82891165f 100644 --- a/src/transports/smart_protocol.c +++ b/src/transports/smart_protocol.c @@ -592,7 +592,9 @@ int git_smart__download_pack( } } else if (pkt->type == GIT_PKT_DATA) { git_pkt_data *p = (git_pkt_data *) pkt; - error = writepack->append(writepack, p->data, p->len, stats); + + 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 */ git__free(pkt); |