forked from mirrors/tar-split
tar/asm: check length before adding an entry
This commit is contained in:
parent
51b0481d4a
commit
df8572a1eb
1 changed files with 18 additions and 13 deletions
|
@ -55,27 +55,32 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io
|
||||||
}
|
}
|
||||||
// even when an EOF is reached, there is often 1024 null bytes on
|
// even when an EOF is reached, there is often 1024 null bytes on
|
||||||
// the end of an archive. Collect them too.
|
// the end of an archive. Collect them too.
|
||||||
|
if b := tr.RawBytes(); len(b) > 0 {
|
||||||
_, err := p.AddEntry(storage.Entry{
|
_, err := p.AddEntry(storage.Entry{
|
||||||
Type: storage.SegmentType,
|
Type: storage.SegmentType,
|
||||||
Payload: tr.RawBytes(),
|
Payload: b,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pW.CloseWithError(err)
|
pW.CloseWithError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break // not return. We need the end of the reader.
|
break // not return. We need the end of the reader.
|
||||||
}
|
}
|
||||||
if hdr == nil {
|
if hdr == nil {
|
||||||
break // not return. We need the end of the reader.
|
break // not return. We need the end of the reader.
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := p.AddEntry(storage.Entry{
|
if b := tr.RawBytes(); len(b) > 0 {
|
||||||
|
_, err := p.AddEntry(storage.Entry{
|
||||||
Type: storage.SegmentType,
|
Type: storage.SegmentType,
|
||||||
Payload: tr.RawBytes(),
|
Payload: b,
|
||||||
}); err != nil {
|
})
|
||||||
|
if err != nil {
|
||||||
pW.CloseWithError(err)
|
pW.CloseWithError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var csum []byte
|
var csum []byte
|
||||||
if hdr.Size > 0 {
|
if hdr.Size > 0 {
|
||||||
|
|
Loading…
Reference in a new issue