Fixes to safely reading the index

Avoid wrapping around extension size when reading, avoid walking off
the end of the buffer when reading names.