Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bce9484

Browse files
phkelleycarlosmn
authored andcommitted
Fix assert when receiving uncommon sideband packet
1 parent cbd930f commit bce9484

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/indexer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
433433
git_map map;
434434
int error;
435435

436+
assert(data && size);
437+
436438
/* the offset needs to be at the beginning of the a page boundary */
437439
page_start = (offset / page_size) * page_size;
438440
page_offset = offset - page_start;
@@ -451,6 +453,9 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
451453
{
452454
git_off_t current_size = idx->pack->mwf.size;
453455

456+
if (!size)
457+
return 0;
458+
454459
/* add the extra space we need at the end */
455460
if (p_ftruncate(idx->pack->mwf.fd, current_size + size) < 0) {
456461
giterr_set(GITERR_OS, "Failed to increase size of pack file '%s'", idx->pack->pack_name);

src/transports/smart_protocol.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,9 @@ int git_smart__download_pack(
592592
}
593593
} else if (pkt->type == GIT_PKT_DATA) {
594594
git_pkt_data *p = (git_pkt_data *) pkt;
595-
error = writepack->append(writepack, p->data, p->len, stats);
595+
596+
if (p->len)
597+
error = writepack->append(writepack, p->data, p->len, stats);
596598
} else if (pkt->type == GIT_PKT_FLUSH) {
597599
/* A flush indicates the end of the packfile */
598600
git__free(pkt);

0 commit comments

Comments
 (0)