Skip to content
Snippets Groups Projects
Commit 606bc7a3 authored by Ronny Nilsson's avatar Ronny Nilsson
Browse files

Fix an index out of bounds error.

parent 2c20ec37
Branches
No related tags found
No related merge requests found
......@@ -536,9 +536,10 @@ static struct metaInfo_t* meta_by_id(int id)
static int meta_find_all(void)
{
struct ubi_vol_info volInfo;
int i, volId, res;
int i, volId, res, medaIdx;
res = 0;
medaIdx = 0;
volId = devInfo.lowest_vol_id - 1;
for(i = 0; i < devInfo.vol_count && volId < UBI_MAX_VOLUMES; i++) {
......@@ -555,21 +556,24 @@ static int meta_find_all(void)
case METAVOLID1:
case METAVOLID2:
case METAVOLID3:
metaInfos[i].found = 1;
metaInfos[i].volInfo = volInfo;
metaInfos[i].nodePath = ubi_path_by_id(devInfo.dev_num, -1);
metaInfos[i].volPath = ubi_path_by_id(devInfo.dev_num, volInfo.vol_id);
if(meta_find_seqno(metaInfos + i)) {
metaInfos[medaIdx].found = 1;
metaInfos[medaIdx].volInfo = volInfo;
metaInfos[medaIdx].nodePath = ubi_path_by_id(devInfo.dev_num, -1);
metaInfos[medaIdx].volPath = ubi_path_by_id(devInfo.dev_num, volInfo.vol_id);
if(meta_find_seqno(metaInfos + medaIdx)) {
if (verbose) {
printf("Found %s in %s but it's corrupt.\n",
volInfo.name, metaInfos[i].volPath);
volInfo.name, metaInfos[medaIdx].volPath);
}
}
else if (verbose) {
printf("Found %s in %s, committed %d, seq %d\n",
volInfo.name, metaInfos[i].volPath,
metaInfos[i].committed, metaInfos[i].seqNo);
volInfo.name, metaInfos[medaIdx].volPath,
metaInfos[medaIdx].committed,
metaInfos[medaIdx].seqNo);
}
if(medaIdx < MAX_METAS) medaIdx++;
break;
default:
......@@ -852,6 +856,7 @@ int gen_image_ubi(char *sequence_number)
metaInfos[i].volPath = NULL;
}
libubi_close(libubi);
libubi = NULL;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment