Skip to content

Commit 04d9b35

Browse files
frankmorgnerJakuje
authored andcommitted
oberthur-awp: fixed possible out of bounds write on card initialization
1 parent e794edd commit 04d9b35

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/pkcs15init/pkcs15-oberthur-awp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,17 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
724724
if (rv < 0)
725725
goto done;
726726

727+
if (lst_file->size < 5) {
728+
rv = SC_ERROR_UNKNOWN_DATA_RECEIVED;
729+
goto done;
730+
}
731+
727732
flags = lst_file->ef_structure;
728733
rv = sc_read_binary(p15card->card, 0, buff, lst_file->size, &flags);
729734
if (rv < 0)
730735
goto done;
731736

732-
for (ii=0; ii < lst_file->size; ii+=5)
737+
for (ii=0; ii <= lst_file->size-5; ii+=5)
733738
if (*(buff + ii) != COSM_LIST_TAG)
734739
break;
735740
if (ii>=lst_file->size) {

0 commit comments

Comments
 (0)