pkcs15init: in sc_pkcs15init_add_object() if DF update fails, remove object from the list before return
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4076 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
dbd315c7e9
commit
70ee7c1438
|
@ -2492,7 +2492,7 @@ sc_pkcs15init_add_object(struct sc_pkcs15_card *p15card,
|
||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
struct sc_pkcs15_df *df;
|
struct sc_pkcs15_df *df;
|
||||||
struct sc_file *file = NULL;
|
struct sc_file *file = NULL;
|
||||||
int is_new = 0, r = 0;
|
int is_new = 0, r = 0, object_added = 0;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, 3);
|
SC_FUNC_CALLED(ctx, 3);
|
||||||
sc_debug(ctx, "add object %p to DF of type %u\n", object, df_type);
|
sc_debug(ctx, "add object %p to DF of type %u\n", object, df_type);
|
||||||
|
@ -2523,12 +2523,16 @@ sc_pkcs15init_add_object(struct sc_pkcs15_card *p15card,
|
||||||
object->df = df;
|
object->df = df;
|
||||||
r = sc_pkcs15_add_object(p15card, object);
|
r = sc_pkcs15_add_object(p15card, object);
|
||||||
SC_TEST_RET(ctx, r, "Failed to add pkcs15 object");
|
SC_TEST_RET(ctx, r, "Failed to add pkcs15 object");
|
||||||
|
object_added = 1;
|
||||||
} else {
|
} else {
|
||||||
/* Reused an existing object */
|
/* Reused an existing object */
|
||||||
assert(object->df == df);
|
assert(object->df == df);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sc_pkcs15init_update_any_df(p15card, profile, df, is_new);
|
r = sc_pkcs15init_update_any_df(p15card, profile, df, is_new);
|
||||||
|
if (r < 0 && object_added)
|
||||||
|
sc_pkcs15_remove_object(p15card, object);
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, 3, r);
|
SC_FUNC_RETURN(ctx, 3, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue