Skip to content

Commit

Permalink
pkcs15init segfault
Browse files Browse the repository at this point in the history
pkcs15init/pkcs15-lib.c in sc_pkcs15init_add_app had:
/* FIXME: what to do if sc_pkcs15init_update_dir failed? */

This fixes the problem.

Fixes: #2398 in that it will not segfault.

 On branch epass2003-init
 Changes to be committed:
	modified:   ../pkcs15init/pkcs15-lib.c
  • Loading branch information
dengert authored and frankmorgner committed Jan 25, 2022
1 parent d85e2d6 commit afab2e6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/pkcs15init/pkcs15-lib.c
Expand Up @@ -912,9 +912,20 @@ sc_pkcs15init_add_app(struct sc_card *card, struct sc_profile *profile,
if (r >= 0) {
r = sc_pkcs15init_update_tokeninfo(p15card, profile);
} else {
/* FIXME: what to do if sc_pkcs15init_update_dir failed? */
free(app->label);
free(app); /* unused */
/* FIXED: what to do if sc_pkcs15init_update_dir failed? */
/* sc_pkcs15init_update_dir may add app to card->app[] */
int found = 0;
int i;
for (i = 0; i < card->app_count; i++) {
if (card->app[i] == app) {
found = 1;
break;
}
}
if (found == 0) { /* not in card->app[] free it */
free(app->label);
free(app); /* unused */
}
}
}
else {
Expand Down

0 comments on commit afab2e6

Please sign in to comment.