pnmdec: make ff_pnm_decode_header() more robust