Simplify iterating over program headers and detect corrupt ones.