Fix off-by-one issue in upgrade_data_format().