Merge pull request #109 from harshavardhana/pr_out_add_crc_checks_for_object_get_

This commit is contained in:
Harshavardhana 2014-12-11 15:10:51 -08:00
commit 94e11db3a8

View File

@ -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
}