diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c index 6774fe17..1e0773aa 100644 --- a/src/libopensc/card-openpgp.c +++ b/src/libopensc/card-openpgp.c @@ -883,7 +883,7 @@ static unsigned int pgp_strip_path(sc_card_t *card, const sc_path_t *path) { unsigned int start_point = 0; /* start_point will move through the path string */ - if (path->value == NULL || path->len == 0) + if (path->len == 0) return 0; /* Ignore 3F00 (MF) at the beginning */ diff --git a/src/libopensc/card-piv.c b/src/libopensc/card-piv.c index b1996541..ca3ebe44 100644 --- a/src/libopensc/card-piv.c +++ b/src/libopensc/card-piv.c @@ -784,8 +784,6 @@ static int piv_find_aid(sc_card_t * card, sc_file_t *aid_file) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NO_CARD_SUPPORT); card->ops->process_fci(card, aid_file, apdu.resp+2, apdu.resp[1]); - if (aid_file->name == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NO_CARD_SUPPORT); SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, i); } diff --git a/src/libopensc/card-tcos.c b/src/libopensc/card-tcos.c index d6362a38..e41db406 100644 --- a/src/libopensc/card-tcos.c +++ b/src/libopensc/card-tcos.c @@ -161,8 +161,6 @@ static int tcos_construct_fci(const sc_file_t *file, /* Directory name */ if (file->type == SC_FILE_TYPE_DF) { if (file->namelen) { - if (file->namelen > 16 || !file->name) - return SC_ERROR_INVALID_ARGUMENTS; sc_asn1_put_tag(0x84, file->name, file->namelen, p, 16, &p); } diff --git a/src/pkcs15init/pkcs15-oberthur-awp.c b/src/pkcs15init/pkcs15-oberthur-awp.c index aa4e20a1..eb0642e5 100644 --- a/src/pkcs15init/pkcs15-oberthur-awp.c +++ b/src/pkcs15init/pkcs15-oberthur-awp.c @@ -782,10 +782,8 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj if (obj->type == COSM_TYPE_PUBKEY_RSA || obj->type == COSM_TYPE_PRKEY_RSA) ki->flags |= COSM_GENERATED; - if (obj->label) { - ki->label.value = (unsigned char *)strdup(obj->label); - ki->label.len = strlen(obj->label); - } + ki->label.value = (unsigned char *)strdup(obj->label); + ki->label.len = strlen(obj->label); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_encode_key_info() label(%i):%s",ki->label.len, ki->label.value); /* @@ -1088,10 +1086,8 @@ awp_encode_data_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob di->flags = 0x0000; - if (obj->label) { - di->label.value = (unsigned char *)strdup(obj->label); - di->label.len = strlen(obj->label); - } + di->label.value = (unsigned char *)strdup(obj->label); + di->label.len = strlen(obj->label); di->app.len = strlen(data_info->app_label); if (di->app.len) { diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c index 0d00c4a4..9a445896 100644 --- a/src/tools/pkcs11-tool.c +++ b/src/tools/pkcs11-tool.c @@ -4217,7 +4217,7 @@ static void test_kpgen_certwrite(CK_SLOT_ID slot, CK_SESSION_HANDLE session) return; tmp = getID(session, priv_key, (CK_ULONG *) &opt_object_id_len); - if (opt_object_id == NULL || opt_object_id_len == 0) { + if (opt_object_id_len == 0) { printf("ERR: newly generated private key has no (or an empty) CKA_ID\n"); return; } @@ -4372,7 +4372,7 @@ static void test_ec(CK_SLOT_ID slot, CK_SESSION_HANDLE session) return; tmp = getID(session, priv_key, (CK_ULONG *) &opt_object_id_len); - if (opt_object_id == NULL || opt_object_id_len == 0) { + if (opt_object_id_len == 0) { printf("ERR: newly generated private key has no (or an empty) CKA_ID\n"); return; } diff --git a/src/tools/pkcs15-init.c b/src/tools/pkcs15-init.c index 81d883c8..c3d6818e 100644 --- a/src/tools/pkcs15-init.c +++ b/src/tools/pkcs15-init.c @@ -1010,8 +1010,7 @@ is_cacert_already_present(struct sc_pkcs15init_certargs *args) if (!cinfo->authority) continue; - if (args->label && objs[i]->label - && strcmp(args->label, objs[i]->label)) + if (strcmp(args->label, objs[i]->label)) continue; /* XXX we should also match the usage field here */ @@ -2839,7 +2838,7 @@ static int verify_pin(struct sc_pkcs15_card *p15card, char *auth_id_str) if (opt_no_prompt) return SC_ERROR_OBJECT_NOT_FOUND; - if (pin_obj->label) + if (0 < strnlen(pin_obj->label, sizeof pin_obj->label)) snprintf(pin_label, sizeof(pin_label), "User PIN [%s]", pin_obj->label); else snprintf(pin_label, sizeof(pin_label), "User PIN"); diff --git a/src/tools/pkcs15-tool.c b/src/tools/pkcs15-tool.c index 8c980bb6..3a4fe622 100644 --- a/src/tools/pkcs15-tool.c +++ b/src/tools/pkcs15-tool.c @@ -455,7 +455,7 @@ static int list_data_objects(void) int idx; struct sc_pkcs15_data_info *cinfo = (struct sc_pkcs15_data_info *) objs[i]->data; - if (objs[i]->label) + if (0 < strnlen(objs[i]->label, sizeof objs[i]->label)) printf("Data object '%s'\n", objs[i]->label); else printf("Data object <%i>\n", i);