sc_file_dup(): copy attributes as well, use explicit assignement and check return values
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2498 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
7ff54c7e2e
commit
f317e2966a
|
@ -381,13 +381,37 @@ void sc_file_dup(sc_file_t **dest, const sc_file_t *src)
|
|||
return;
|
||||
*dest = newf;
|
||||
|
||||
*newf = *src;
|
||||
memcpy(&newf->path, &src->path, sizeof(struct sc_path));
|
||||
memcpy(&newf->name, &src->name, sizeof(src->name));
|
||||
newf->namelen = src->namelen;
|
||||
newf->type = src->type;
|
||||
newf->shareable = src->shareable;
|
||||
newf->ef_structure = src->ef_structure;
|
||||
newf->size = src->size;
|
||||
newf->id = src->id;
|
||||
newf->status = src->status;
|
||||
for (op = 0; op < SC_MAX_AC_OPS; op++) {
|
||||
newf->acl[op] = NULL;
|
||||
e = sc_file_get_acl_entry(src, op);
|
||||
if (e != NULL)
|
||||
sc_file_add_acl_entry(newf, op, e->method, e->key_ref);
|
||||
if (e != NULL) {
|
||||
if (sc_file_add_acl_entry(newf, op, e->method, e->key_ref) < 0)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
newf->record_length = src->record_length;
|
||||
newf->record_count = src->record_count;
|
||||
|
||||
if (sc_file_set_sec_attr(newf, src->sec_attr, src->sec_attr_len) < 0)
|
||||
goto err;
|
||||
if (sc_file_set_prop_attr(newf, src->prop_attr, src->prop_attr_len) < 0)
|
||||
goto err;
|
||||
if (sc_file_set_type_attr(newf, src->type_attr, src->type_attr_len) < 0)
|
||||
goto err;
|
||||
return;
|
||||
err:
|
||||
if (newf != NULL)
|
||||
sc_file_free(newf);
|
||||
*dest = NULL;
|
||||
}
|
||||
|
||||
int sc_file_set_sec_attr(sc_file_t *file, const u8 *sec_attr,
|
||||
|
|
Loading…
Reference in New Issue