Skip to content

Commit c32133b

Browse files
committedMay 27, 2015
flash_storage: avoid crash if a record size gets corrupted to be less than 6
1 parent 4bf7875 commit c32133b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎soc/runtime/flash_storage.c

+7
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ static int record_iter_next(struct iter_state *is, struct record *record, int *f
6161
if(record->size == END_MARKER)
6262
return 0;
6363

64+
if(record->size < 6) {
65+
printf("flash_storage might be corrupted: record size is %u (<6) at address %08x\n", record->size, record->raw_record);
66+
if(fatal)
67+
*fatal = 1;
68+
return 0;
69+
}
70+
6471
if(is->seek > is->buf_len - sizeof(record->size) - 2) { /* 2 is the minimum key length */
6572
printf("flash_storage might be corrupted: END_MARKER missing at the end of the storage sector\n");
6673
if(fatal)

0 commit comments

Comments
 (0)
Please sign in to comment.