libgit2/libgit2 — pull request #2447 by phkelley (2014-06-27 15:53:35+00:00)
Title: Fix assert when receiving uncommon sideband packet

If during pack download, we receive a 5-byte packet equal to "0005\x1", then a packet of type GIT_PKT_DATA is created with length 0. When we try to append this packet to a pack file, a long chain of invoked functions ends up failing to handle the no-op case of zero length. We should guard against this any time one of these functions might be invoked with a zero length.

Stack trace:
```
libgit2_clar!_wassert+0x108
libgit2_clar!p_mmap+0x99 [x:\libgit2\src\win32\map.c @ 42]
libgit2_clar!write_at+0xcf [x:\libgit2\src\indexer.c @ 442]
libgit2_clar!append_to_pack+0x96 [x:\libgit2\src\indexer.c @ 463]
libgit2_clar!git_indexer_append+0xc6 [x:\libgit2\src\indexer.c @ 476]
libgit2_clar!pack_backend__writepack_append+0x77 [x:\libgit2\src\odb_pack.c @ 542]
libgit2_clar!git_smart__download_pack+0x30d [x:\libgit2\src\transports\smart_protocol.c @ 595]
libgit2_clar!git_fetch_download_pack+0x85 [x:\libgit2\src\fetch.c @ 139]
libgit2_clar!git_remote_download+0xe3 [x:\libgit2\src\remote.c @ 840]
libgit2_clar!git_remote_fetch+0x70 [x:\libgit2\src\remote.c @ 854]
libgit2_clar!git_clone_into+0x192 [x:\libgit2\src\clone.c @ 353]
libgit2_clar!git_clone+0x2bd [x:\libgit2\src\clone.c @ 430]
```