Apply patch from joe@reactionis.co.uk which fixes a buffer overflow on broken/malicious fits files. (cherry picked from commit ace45631)