astrogo / fitsio

fitsio is a pure-Go package to read and write `FITS` files
BSD 3-Clause "New" or "Revised" License
53 stars 24 forks source link

Decode: check that the number of bytes read matches the number of bytes requested #36

Closed airnandez closed 6 years ago

airnandez commented 6 years ago

When decoding a FITS file, an io.Reader can return both the requested number of bytes AND an error (for instance EOF).

Here we should first check that the requested number of bytes were returned (here pad), in which case err can be either ignored or, best, checked against EOF.

sbinet commented 6 years ago

right. I think it actually would be better to use io.ReadFull. (care to send a PR?)

sbinet commented 6 years ago

(I am on holidays till 1st of March)

airnandez commented 6 years ago

Yes, using io.ReadFull would be better. I will try something on my side and send a PR.

sbinet commented 6 years ago

Thanks!

airnandez commented 6 years ago

Pull request submitted.

sbinet commented 6 years ago

fixed with a1d964b.