fixed compiler warnings (partially submitted)

Signed-off-by: Frank Morgner <morgner@informatik.hu-berlin.de>

PR-222: commit 0b567dbaa8
partially submitted by Viktor Tarasov
This commit is contained in:
Frank Morgner 2014-02-25 09:07:09 +01:00 committed by Viktor Tarasov
parent 883d42b1f8
commit a64326e768
26 changed files with 53 additions and 64 deletions

View File

@ -1001,7 +1001,7 @@ static int asn1_decode_se_info(sc_context_t *ctx, const u8 *obj, size_t objlen,
ret = SC_SUCCESS;
err:
if (ret != SC_SUCCESS) {
int i;
size_t i;
for (i = 0; i < idx; i++)
if (ses[i])
free(ses[i]);

View File

@ -1702,7 +1702,7 @@ static int
authentic_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, int *tries_left)
{
struct sc_context *ctx = card->ctx;
int rv;
int rv = SC_ERROR_INTERNAL;
LOG_FUNC_CALLED(ctx);
sc_log(ctx, "PIN-CMD:%X,PIN(type:%X,ret:%i)", data->cmd, data->pin_type, data->pin_reference);
@ -2284,9 +2284,9 @@ authentic_sm_free_wrapped_apdu(struct sc_card *card, struct sc_apdu *plain, stru
}
if ((*sm_apdu)->data)
free((*sm_apdu)->data);
free((unsigned char *) (*sm_apdu)->data);
if ((*sm_apdu)->resp)
free((*sm_apdu)->resp);
free((unsigned char *) (*sm_apdu)->resp);
free(*sm_apdu);
*sm_apdu = NULL;
@ -2337,7 +2337,7 @@ authentic_sm_get_wrapped_apdu(struct sc_card *card, struct sc_apdu *plain, struc
if (!apdu->data)
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
if (plain->data && plain->datalen)
memcpy(apdu->data, plain->data, plain->datalen);
memcpy((unsigned char *) apdu->data, plain->data, plain->datalen);
apdu->resp = calloc (1, plain->resplen + 32);
if (!apdu->resp)

View File

@ -874,7 +874,7 @@ cardos_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
}
else {
/* check the the algorithmIDs from the AlgorithmInfo */
int i;
size_t i;
for(i=0; i<algorithm_ids_in_tokeninfo_count;++i){
unsigned int id = algorithm_ids_in_tokeninfo[i];
if(id == 0x86 || id == 0x88)

View File

@ -852,7 +852,7 @@ epass2003_sm_free_wrapped_apdu(struct sc_card *card,
rv = epass2003_sm_unwrap_apdu(card, *sm_apdu, plain);
if ((*sm_apdu)->data)
free((*sm_apdu)->data);
free((unsigned char *) (*sm_apdu)->data);
if ((*sm_apdu)->resp)
free((*sm_apdu)->resp);
free(*sm_apdu);

View File

@ -856,9 +856,7 @@ cyberflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file,
u8 *buf, size_t *buflen)
{
u8 *p = buf;
int i;
size_t size = file->size;
int ops[6];
/* cyberflex wants input parameters length added */
switch (file->type) {
@ -903,20 +901,6 @@ cyberflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file,
return -1;
}
p[5] = 0x01; /* status?? */
for (i = 0; i < 6; i++)
ops[i] = -1;
if (file->type == SC_FILE_TYPE_DF) {
ops[0] = SC_AC_OP_LIST_FILES;
ops[2] = SC_AC_OP_DELETE;
ops[3] = SC_AC_OP_CREATE;
} else {
ops[0] = SC_AC_OP_READ;
ops[1] = SC_AC_OP_UPDATE;
ops[2] = SC_AC_OP_READ;
ops[3] = SC_AC_OP_UPDATE;
ops[4] = SC_AC_OP_REHABILITATE;
ops[5] = SC_AC_OP_INVALIDATE;
}
p[6] = p[7] = 0;
*buflen = 16;

View File

@ -642,7 +642,7 @@ static int jcop_set_security_env(sc_card_t *card,
if (tmp.algorithm_flags & SC_ALGORITHM_RSA_HASH_MD5)
tmp.algorithm_ref |= 0x20;
memcpy(env, &tmp, sizeof(struct sc_security_env));
memcpy((sc_security_env_t *) env, &tmp, sizeof(struct sc_security_env));
}
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0xC1, 0);

View File

@ -1758,7 +1758,7 @@ auth_pin_change(struct sc_card *card, unsigned int type,
struct sc_pin_cmd_data *data, int *tries_left)
{
struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
int rv;
int rv = SC_ERROR_INTERNAL;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
@ -1905,7 +1905,7 @@ auth_pin_reset(struct sc_card *card, unsigned int type,
static int
auth_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, int *tries_left)
{
int rv;
int rv = SC_ERROR_INTERNAL;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
if (data->pin_type != SC_AC_CHV)

View File

@ -651,7 +651,7 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
/* FIXME sc_format_path expects an hex string of an file
* identifier. ushort2bebytes instead delivers a two bytes binary
* string */
sc_format_path(ushort2bebytes(id_str, file_id), &blob->file->path);
sc_format_path((char *) ushort2bebytes(id_str, file_id), &blob->file->path);
}
/* find matching DO info: set file type depending on it */
@ -1687,7 +1687,7 @@ pgp_parse_and_set_pubkey_output(sc_card_t *card, u8* data, size_t data_len,
LOG_TEST_RET(card->ctx, r, "Cannot store creation time");
/* Parse response. Ref: pgp_enumerate_blob() */
while (data_len > (in - data)) {
while (data_len > (size_t) (in - data)) {
unsigned int cla, tag, tmptag;
size_t len;
u8 *part = in;

View File

@ -2012,7 +2012,7 @@ static int piv_compute_signature(sc_card_t *card,
piv_private_data_t * priv = PIV_DATA(card);
int r;
int i;
int nLen;
size_t nLen;
u8 rbuf[128]; /* For EC conversions 384 will fit */
size_t rbuflen = sizeof(rbuf);
const u8 * body;

View File

@ -55,7 +55,7 @@ sc_pkcs15_read_data_object(struct sc_pkcs15_card *p15card,
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
if (!info->data.value) {
r = sc_pkcs15_read_file(p15card, &info->path, &info->data.value, &info->data.len);
r = sc_pkcs15_read_file(p15card, &info->path, (unsigned char **) &info->data.value, (size_t *) &info->data.len);
LOG_TEST_RET(ctx, r, "Cannot get DATA object data");
}

View File

@ -125,8 +125,8 @@ static int piv_get_guid(struct sc_pkcs15_card *p15card, const struct sc_pkcs15_o
struct sc_serial_number serialnr;
struct sc_pkcs15_id id;
unsigned char guid_bin[SC_PKCS15_MAX_ID_SIZE + SC_MAX_SERIALNR];
size_t bin_size, offs, tlen;
int r, i;
size_t bin_size, offs, tlen, i;
int r;
unsigned char fbit, fbits, fbyte, fbyte2, fnibble;
unsigned char *f5p, *f8p;
@ -219,7 +219,7 @@ static int piv_get_guid(struct sc_pkcs15_card *p15card, const struct sc_pkcs15_o
offs = tlen - bin_size;
for (i=0; i<bin_size; i++)
sprintf(out + i*2, "%02x", guid_bin[offs + i]);
sprintf((char *) out + i*2, "%02x", guid_bin[offs + i]);
return SC_SUCCESS;
}

View File

@ -85,7 +85,7 @@ int sc_pkcs15_decipher(struct sc_pkcs15_card *p15card,
{
sc_context_t *ctx = p15card->card->ctx;
int r;
sc_algorithm_info_t *alg_info;
sc_algorithm_info_t *alg_info = NULL;
sc_security_env_t senv;
const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data;
unsigned long pad_flags = 0, sec_flags = 0;
@ -190,7 +190,7 @@ int sc_pkcs15_derive(struct sc_pkcs15_card *p15card,
{
sc_context_t *ctx = p15card->card->ctx;
int r;
sc_algorithm_info_t *alg_info;
sc_algorithm_info_t *alg_info = NULL;
sc_security_env_t senv;
const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data;
unsigned long pad_flags = 0, sec_flags = 0;

View File

@ -38,6 +38,10 @@
#include <openssl/sha.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
static const struct sc_asn1_entry c_asn1_twlabel[] = {
{ "twlabel", SC_ASN1_UTF8STRING, SC_ASN1_TAG_UTF8STRING, 0, NULL, NULL },
{ NULL, 0, 0, 0, NULL, NULL }
@ -1261,7 +1265,6 @@ __sc_pkcs15_search_objects(struct sc_pkcs15_card *p15card, unsigned int class_ma
struct sc_pkcs15_df *df = NULL;
unsigned int df_mask = 0;
size_t match_count = 0;
int r = 0;
if (type)
class_mask |= SC_PKCS15_TYPE_TO_CLASS(type);
@ -1300,7 +1303,8 @@ __sc_pkcs15_search_objects(struct sc_pkcs15_card *p15card, unsigned int class_ma
continue;
/* Enumerate the DF's, so p15card->obj_list is
* populated. */
r = sc_pkcs15_parse_df(p15card, df);
/* FIXME dont ignore errors */
sc_pkcs15_parse_df(p15card, df);
}
/* And now loop over all objects */
@ -2533,7 +2537,6 @@ sc_pkcs15_get_supported_algo(struct sc_pkcs15_card *p15card, unsigned operation,
return info;
}
int
sc_pkcs15_get_generalized_time(struct sc_context *ctx, char **out)
{

View File

@ -1939,7 +1939,6 @@ pkcs15_create_private_key(struct sc_pkcs11_slot *slot, struct sc_profile *profil
struct sc_pkcs15_auth_info *pin = NULL;
CK_KEY_TYPE key_type;
struct sc_pkcs15_prkey_rsa *rsa = NULL;
struct sc_pkcs15_prkey_ec *ec = NULL;
struct sc_pkcs15_prkey_gostr3410 *gost = NULL;
int rc, rv;
char label[SC_PKCS15_MAX_LABEL_SIZE];
@ -1969,7 +1968,6 @@ pkcs15_create_private_key(struct sc_pkcs11_slot *slot, struct sc_profile *profil
break;
case CKK_EC:
args.key.algorithm = SC_ALGORITHM_EC;
ec = &args.key.u.ec;
/* TODO: -DEE Do not have PKCS15 card with EC to test this */
/* fall through */
default:

View File

@ -333,7 +333,7 @@ CK_RV C_InitPIN(CK_SESSION_HANDLE hSession, CK_CHAR_PTR pPin, CK_ULONG ulPinLen)
struct sc_pkcs11_session *session;
struct sc_pkcs11_slot *slot;
sc_log(context, "C_InitPIN() called, pin '%s'", pPin ? pPin : "<null>");
sc_log(context, "C_InitPIN() called, pin '%s'", pPin ? (char *) pPin : "<null>");
if (pPin == NULL_PTR && ulPinLen > 0)
return CKR_ARGUMENTS_BAD;

View File

@ -185,7 +185,8 @@ CK_RV card_detect(sc_reader_t *reader)
struct sc_pkcs11_card *p11card = NULL;
int rc;
CK_RV rv;
unsigned int i, j;
unsigned int i;
int j;
rv = CKR_OK;

View File

@ -172,10 +172,11 @@ cardos_select_pin_reference(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
preferred++;
}
if (current > preferred || preferred > CARDOS_PIN_ID_MAX)
if (preferred > CARDOS_PIN_ID_MAX)
return SC_ERROR_TOO_MANY_OBJECTS;
auth_info->attrs.pin.reference = preferred;
return 0;
return SC_SUCCESS;
}
/*

View File

@ -327,7 +327,7 @@ iasecc_file_convert_acls(struct sc_context *ctx, struct sc_profile *profile, str
/* FIXME the acl object must not be modified, it is only defined in
* sc_file_get_acl_entry. Accessing it here means we have a race
* condition. */
struct sc_acl_entry *acl = sc_file_get_acl_entry(file, ii);
struct sc_acl_entry *acl = (struct sc_acl_entry *) sc_file_get_acl_entry(file, ii);
if (acl) {
switch (acl->method) {

View File

@ -191,10 +191,11 @@ incrypto34_select_pin_reference(sc_profile_t *profile, sc_pkcs15_card_t *p15card
preferred++;
}
if (current > preferred || preferred > INCRYPTO34_PIN_ID_MAX)
if (preferred > INCRYPTO34_PIN_ID_MAX)
return SC_ERROR_TOO_MANY_OBJECTS;
auth_info->attrs.pin.reference = preferred;
return 0;
return SC_SUCCESS;
}
/*

View File

@ -114,8 +114,6 @@ static int check_key_compatibility(struct sc_pkcs15_card *,
static int prkey_fixup(struct sc_pkcs15_card *, struct sc_pkcs15_prkey *);
static int prkey_bits(struct sc_pkcs15_card *, struct sc_pkcs15_prkey *);
static int prkey_pkcs15_algo(struct sc_pkcs15_card *, struct sc_pkcs15_prkey *);
static int select_intrinsic_id(struct sc_pkcs15_card *, struct sc_profile *,
int, struct sc_pkcs15_id *, void *);
static int select_id(struct sc_pkcs15_card *, int, struct sc_pkcs15_id *);
static int select_object_path(struct sc_pkcs15_card *, struct sc_profile *,
struct sc_pkcs15_object *, struct sc_path *);
@ -1481,7 +1479,7 @@ sc_pkcs15init_store_public_key(struct sc_pkcs15_card *p15card, struct sc_profile
struct sc_pkcs15_pubkey key;
struct sc_path *path;
const char *label;
unsigned int keybits, type, usage;
unsigned int keybits, type = 0, usage;
int r;
LOG_FUNC_CALLED(ctx);

View File

@ -1565,7 +1565,7 @@ awp_update_df_create(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
struct sc_pkcs15_object *object)
{
struct sc_context *ctx = p15card->card->ctx;
int rv;
int rv = SC_ERROR_INTERNAL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
if (!object)
@ -1891,7 +1891,7 @@ awp_update_df_delete(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
struct sc_pkcs15_object *object)
{
struct sc_context *ctx = p15card->card->ctx;
int rv;
int rv = SC_ERROR_INTERNAL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
if (!object)

View File

@ -312,8 +312,8 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_
unsigned char sbuf[0x400];
DES_cblock cblock, icv;
unsigned char *encrypted = NULL, edfb_data[0x200], mac_data[0x200];
size_t encrypted_len, edfb_len = 0, mac_len = 0;
int rv, offs;
size_t encrypted_len, edfb_len = 0, mac_len = 0, offs;
int rv;
LOG_FUNC_CALLED(ctx);
sc_log(ctx, "securize APDU (cla:%X,ins:%X,p1:%X,p2:%X,data(%i):%p)",

View File

@ -41,9 +41,9 @@ static struct {
{"DF01C100", 1, "Telesec Authentifizierungs Zertifikat"},
{"DF014371", 0, "User Authentifizierungs Zertifikat1"},
{"DF014372", 0, "User Authentifizierungs Zertifikat2"},
{"DF01C200", 1, "Telesec Verschlüsselungs Zertifikat"},
{"DF0143B1", 0, "User Verschlüsselungs Zertifikat1"},
{"DF0143B2", 0, "User Verschlüsselungs Zertifikat2"},
{"DF01C200", 1, "Telesec Verschluesselungs Zertifikat"},
{"DF0143B1", 0, "User Verschluesselungs Zertifikat1"},
{"DF0143B2", 0, "User Verschluesselungs Zertifikat2"},
};
static struct {

View File

@ -298,6 +298,7 @@ static int decode_options(int argc, char **argv)
static int do_userinfo(sc_card_t *card)
{
int i;
/* FIXME there are no length checks on buf. */
unsigned char buf[2048];
for (i = 0; openpgp_data[i].ef != NULL; i++) {
@ -339,7 +340,7 @@ static int do_userinfo(sc_card_t *card)
buf[file->size] = '\0';
if (file->size > 0) {
display_data(openpgp_data + i, buf);
display_data(openpgp_data + i, (char *) buf);
}
}
@ -402,7 +403,7 @@ int do_verify(sc_card_t *card, char *type, char *pin)
data.cmd = SC_PIN_CMD_VERIFY;
data.pin_type = SC_AC_CHV;
data.pin_reference = type[3] - '0';
data.pin1.data = pin;
data.pin1.data = (unsigned char *) pin;
data.pin1.len = strlen(pin);
r = sc_pin_cmd(card, &data, &tries_left);
return r;

View File

@ -4154,7 +4154,7 @@ static void test_kpgen_certwrite(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
CK_OBJECT_HANDLE pub_key, priv_key;
CK_ULONG i, num_mechs = 0;
CK_RV rv;
CK_BYTE buf[20], *tmp, *mod;
CK_BYTE buf[20], *tmp;
CK_BYTE md5_and_digestinfo[34] = "\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05\x05\x00\x04\x10";
CK_BYTE *data, sig[512];
CK_ULONG data_len, sig_len;
@ -4203,7 +4203,7 @@ static void test_kpgen_certwrite(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
memcpy(opt_object_id, tmp, opt_object_id_len);
/* This is done in NSS */
mod = getMODULUS(session, priv_key, &mod_len);
getMODULUS(session, priv_key, &mod_len);
if (mod_len < 5 || mod_len > 10000) { /* should be resonable limits */
printf("ERR: GetAttribute(privkey, CKA_MODULUS) doesn't seem to work\n");
return;
@ -4321,7 +4321,7 @@ static void test_ec(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
CK_OBJECT_HANDLE pub_key, priv_key;
CK_ULONG i, num_mechs = 0;
CK_RV rv;
CK_BYTE *tmp, *ec_params, *ec_point;
CK_BYTE *tmp;
CK_BYTE *data_to_sign = (CK_BYTE *)"My Heart's in the Highland";
CK_BYTE *data, sig[512];
CK_ULONG data_len, sig_len;
@ -4358,12 +4358,12 @@ static void test_ec(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
memcpy(opt_object_id, tmp, opt_object_id_len);
/* This is done in NSS */
ec_params = getEC_PARAMS(session, priv_key, &ec_params_len);
getEC_PARAMS(session, priv_key, &ec_params_len);
if (ec_params_len < 5 || ec_params_len > 10000) {
printf("ERR: GetAttribute(privkey, CKA_EC_PARAMS) doesn't seem to work\n");
return;
}
ec_point = getEC_POINT(session, pub_key, &ec_point_len);
getEC_POINT(session, pub_key, &ec_point_len);
if (ec_point_len < 5 || ec_point_len > 10000) {
printf("ERR: GetAttribute(pubkey, CKA_EC_POINT) doesn't seem to work\n");
return;

View File

@ -1822,6 +1822,8 @@ int main(int argc, char * const argv[])
int action_count = 0;
sc_context_param_t ctx_param;
c = OPT_PUK;
while (1) {
c = getopt_long(argc, argv, "r:cuko:va:LR:CwDTU", options, &long_optind);
if (c == -1)