harden packet tostring method against imperfectly formed packets