Skip to content

Commit

Permalink
flash_storage: avoid crash if a record size gets corrupted to be less…
Browse files Browse the repository at this point in the history
… than 6
fallen committed May 27, 2015
1 parent 4bf7875 commit c32133b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions soc/runtime/flash_storage.c
Original file line number Diff line number Diff line change
@@ -61,6 +61,13 @@ static int record_iter_next(struct iter_state *is, struct record *record, int *f
if(record->size == END_MARKER)
return 0;

if(record->size < 6) {
printf("flash_storage might be corrupted: record size is %u (<6) at address %08x\n", record->size, record->raw_record);
if(fatal)
*fatal = 1;
return 0;
}

if(is->seek > is->buf_len - sizeof(record->size) - 2) { /* 2 is the minimum key length */
printf("flash_storage might be corrupted: END_MARKER missing at the end of the storage sector\n");
if(fatal)

0 comments on commit c32133b

Please sign in to comment.