Fix panic when fileSize is negative (#3089)

This commit is contained in:
WithoutPants 2022-11-08 10:01:32 +11:00 committed by GitHub
parent f1c454eb09
commit 962bc7df4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -48,8 +48,8 @@ func oshash(size int64, head []byte, tail []byte) (string, error) {
// FromFilePath calculates the hash reading from src.
func FromReader(src io.ReadSeeker, fileSize int64) (string, error) {
if fileSize == 0 {
return "", nil
if fileSize <= 0 {
return "", fmt.Errorf("cannot calculate oshash for empty file (size %d)", fileSize)
}
fileChunkSize := chunkSize