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