summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kelley <phkelley@hotmail.com>2014-06-27 11:51:35 -0400
committerCarlos Martín Nieto <cmn@dwim.me>2015-01-09 12:42:26 +0100
commitbce9484813ad6aa3d365b11d5f6171e7f33cbbc5 (patch)
treef230dbd11f16f3b24ce2c59183565e19519c86e3
parentcbd930f3f526c8694a4c31157917078ae5f91df3 (diff)
downloadlibgit2-0.21.4.tar.gz
Fix assert when receiving uncommon sideband packetv0.21.4
-rw-r--r--src/indexer.c5
-rw-r--r--src/transports/smart_protocol.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 0b1cf3c75..1f59afa3c 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -433,6 +433,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;
@@ -451,6 +453,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_set(GITERR_OS, "Failed to increase size of pack file '%s'", idx->pack->pack_name);
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);