check return values

This commit is contained in:
Frank Morgner 2015-02-03 00:51:04 +01:00
parent 47df45f5f2
commit ed9572422f
7 changed files with 31 additions and 24 deletions

View File

@ -1654,9 +1654,7 @@ authentic_pin_reset(struct sc_card *card, struct sc_pin_cmd_data *data, int *tri
}
if (save_current) {
struct sc_file *dummy_file = NULL;
rv = authentic_select_file(card, &save_current->path, &dummy_file);
rv = authentic_select_file(card, &save_current->path, NULL);
LOG_TEST_RET(ctx, rv, "Cannot return to saved PATH");
}
LOG_FUNC_RETURN(ctx, rv);

View File

@ -226,7 +226,7 @@ static int parse_emu_block(sc_pkcs15_card_t *p15card, scconf_block *conf)
void *handle = NULL;
int (*init_func)(sc_pkcs15_card_t *);
int (*init_func_ex)(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
int r, force = 0;
int r;
const char *driver, *module_name;
driver = conf->name->data;
@ -236,8 +236,6 @@ static int parse_emu_block(sc_pkcs15_card_t *p15card, scconf_block *conf)
memset(&opts, 0, sizeof(opts));
opts.blk = conf;
if (force != 0)
opts.flags = SC_PKCS15EMU_FLAGS_NO_CHECK;
module_name = scconf_get_str(conf, "module", builtin_name);
if (!strcmp(module_name, "builtin")) {

View File

@ -487,7 +487,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
(struct sc_pkcs15_prkey_info *)obj->data;
size_t idx = key_info->key_reference;
size_t keybits = key_info->modulus_length;
struct sc_file *tfile = NULL, *prkf = NULL, *pukf = NULL;
struct sc_file *tfile = NULL, *pukf = NULL;
struct sc_path path;
struct sc_file *file = NULL;
int fidl = 0;
@ -627,8 +627,6 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
failed:
if (pukf)
sc_file_free(pukf);
if (prkf)
sc_file_free(prkf);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
}

View File

@ -312,7 +312,6 @@ awp_create_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
struct sc_context *ctx = p15card->card->ctx;
struct sc_file *clist = NULL, *file = NULL;
int rv = 0;
unsigned char *list = NULL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create container(%X:%X:%X)", acc->prkey_id, acc->cert_id, acc->pubkey_id);
@ -330,8 +329,6 @@ awp_create_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
rv = awp_create_container_record(p15card, profile, file, acc);
if (list)
free(list);
sc_file_free(file);
sc_file_free(clist);

View File

@ -266,7 +266,6 @@ cosm_create_reference_data(struct sc_profile *profile, struct sc_pkcs15_card *p1
struct sc_card *card = p15card->card;
struct sc_pkcs15_auth_info profile_auth_pin, profile_auth_puk;
struct sc_cardctl_oberthur_createpin_info args;
unsigned char *puk_buff = NULL;
int rv;
unsigned char oberthur_puk[16] = {
0x6F, 0x47, 0xD9, 0x88, 0x4B, 0x6F, 0x9D, 0xC5,
@ -323,9 +322,6 @@ cosm_create_reference_data(struct sc_profile *profile, struct sc_pkcs15_card *p1
sc_file_free(file);
}
if (puk_buff)
free(puk_buff);
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
}

View File

@ -40,7 +40,10 @@ static int enum_pins(struct sc_pkcs15_object ***ret)
fprintf(stderr, "Not enough memory!\n");
return 1;
}
sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, n);
if (0 > sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, n)) {
fprintf(stderr, "Error enumerating PIN codes\n");
return 1;
}
for (i = 0; i < n; i++) {
sc_test_print_object(objs[i]);
}

View File

@ -3802,17 +3802,26 @@ static int wrap_unwrap(CK_SESSION_HANDLE session,
printf(" %s: ", OBJ_nid2sn(EVP_CIPHER_nid(algo)));
EVP_SealInit(&seal_ctx, algo,
if (!EVP_SealInit(&seal_ctx, algo,
&key, &key_len,
iv, &pkey, 1);
iv, &pkey, 1)) {
printf("Internal error.\n");
return 1;
}
/* Encrypt something */
len = sizeof(ciphered);
EVP_SealUpdate(&seal_ctx, ciphered, &len, (const unsigned char *) "hello world", 11);
if (!EVP_SealUpdate(&seal_ctx, ciphered, &len, (const unsigned char *) "hello world", 11)) {
printf("Internal error.\n");
return 1;
}
ciphered_len = len;
len = sizeof(ciphered) - ciphered_len;
EVP_SealFinal(&seal_ctx, ciphered + ciphered_len, &len);
if (!EVP_SealFinal(&seal_ctx, ciphered + ciphered_len, &len)) {
printf("Internal error.\n");
return 1;
}
ciphered_len += len;
EVP_PKEY_free(pkey);
@ -3846,15 +3855,23 @@ static int wrap_unwrap(CK_SESSION_HANDLE session,
return 1;
}
if (!EVP_DecryptInit(&seal_ctx, algo, key, iv))
if (!EVP_DecryptInit(&seal_ctx, algo, key, iv)) {
printf("Internal error.\n");
return 1;
}
len = sizeof(cleartext);
EVP_DecryptUpdate(&seal_ctx, cleartext, &len, ciphered, ciphered_len);
if (!EVP_DecryptUpdate(&seal_ctx, cleartext, &len, ciphered, ciphered_len)) {
printf("Internal error.\n");
return 1;
}
cleartext_len = len;
len = sizeof(cleartext) - len;
EVP_DecryptFinal(&seal_ctx, cleartext + cleartext_len, &len);
if (!EVP_DecryptFinal(&seal_ctx, cleartext + cleartext_len, &len)) {
printf("Internal error.\n");
return 1;
}
cleartext_len += len;
if (cleartext_len != 11