mirror of https://github.com/restic/restic.git
check: use ReadFull to load pack header in checkPack
This ensures that the pack header is actually read completely. Previously, for a truncated file it was possible to only read a part of the header, as backend.Load(...) is not guaranteed to return as many bytes as requested by the length parameter.
This commit is contained in:
parent
8f8d872a68
commit
74d90653e0
|
@ -605,11 +605,13 @@ func checkPackInner(ctx context.Context, r restic.Repository, id restic.ID, blob
|
|||
if err != nil {
|
||||
return &partialReadError{err}
|
||||
}
|
||||
curPos += minHdrStart - curPos
|
||||
}
|
||||
|
||||
// read remainder, which should be the pack header
|
||||
var err error
|
||||
hdrBuf, err = io.ReadAll(bufRd)
|
||||
hdrBuf = make([]byte, int(size-int64(curPos)))
|
||||
_, err = io.ReadFull(bufRd, hdrBuf)
|
||||
if err != nil {
|
||||
return &partialReadError{err}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue