mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Don't crash on reading empty index
This commit is contained in:
parent
bfe935b5ab
commit
8589a0fb40
@ -69,19 +69,22 @@ func (r *marshalReader) readHeader() header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *marshalReader) readIndex() []FileInfo {
|
func (r *marshalReader) readIndex() []FileInfo {
|
||||||
|
var files []FileInfo
|
||||||
nfiles := r.readUint32()
|
nfiles := r.readUint32()
|
||||||
files := make([]FileInfo, nfiles)
|
if nfiles > 0 {
|
||||||
for i := range files {
|
files = make([]FileInfo, nfiles)
|
||||||
files[i].Name = r.readString()
|
for i := range files {
|
||||||
files[i].Flags = r.readUint32()
|
files[i].Name = r.readString()
|
||||||
files[i].Modified = int64(r.readUint64())
|
files[i].Flags = r.readUint32()
|
||||||
nblocks := r.readUint32()
|
files[i].Modified = int64(r.readUint64())
|
||||||
blocks := make([]BlockInfo, nblocks)
|
nblocks := r.readUint32()
|
||||||
for j := range blocks {
|
blocks := make([]BlockInfo, nblocks)
|
||||||
blocks[j].Length = r.readUint32()
|
for j := range blocks {
|
||||||
blocks[j].Hash = r.readBytes()
|
blocks[j].Length = r.readUint32()
|
||||||
|
blocks[j].Hash = r.readBytes()
|
||||||
|
}
|
||||||
|
files[i].Blocks = blocks
|
||||||
}
|
}
|
||||||
files[i].Blocks = blocks
|
|
||||||
}
|
}
|
||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user