Add crc checks for Object Get()

master
Harshavardhana 10 years ago
parent b3af234ee2
commit 1166557da1
  1. 8
      pkgs/storage/appendstorage/append_storage.go

@ -68,12 +68,20 @@ func (storage *appendStorage) Get(objectPath string) (io.Reader, error) {
offset := header.Offset
length := header.Length
crc := header.Crc
object := make([]byte, length)
_, err := storage.file.ReadAt(object, offset)
if err != nil {
return nil, err
}
newcrc, err := crc32c.Crc32c(object)
if err != nil {
return nil, err
}
if newcrc != crc {
return nil, err
}
return bytes.NewBuffer(object), nil
}

Loading…
Cancel
Save