Use size_t instead of int when needed, plus some other minor changes
Patch bug.1 included in Ticket #176 git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3510 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
8624796f37
commit
91177e51ec
|
@ -51,7 +51,7 @@ typedef struct mscsfs {
|
|||
int (*listFile)(mscfs_file_t *fileOut, int reset, void* udata);
|
||||
} mscfs_t;
|
||||
|
||||
mscfs_t *mscfs_new();
|
||||
mscfs_t *mscfs_new(void);
|
||||
void mscfs_free(mscfs_t *fs);
|
||||
void mscfs_clear_cache(mscfs_t* fs);
|
||||
int mscfs_push_file(mscfs_t* fs, mscfs_file_t *file);
|
||||
|
|
|
@ -316,7 +316,7 @@ int msc_verify_pin(sc_card_t *card, int pinNumber, const u8 *pinValue, int pinLe
|
|||
void msc_verify_pin_apdu(sc_card_t *card, sc_apdu_t *apdu, u8* buffer, size_t bufferLength, int pinNumber, const u8 *pinValue, int pinLength)
|
||||
{
|
||||
assert(buffer);
|
||||
assert(bufferLength >= pinLength);
|
||||
assert(bufferLength >= (size_t)pinLength);
|
||||
assert(pinLength <= MSC_MAX_PIN_LENGTH);
|
||||
|
||||
truncatePinNulls(pinValue, &pinLength);
|
||||
|
@ -360,7 +360,7 @@ int msc_unblock_pin(sc_card_t *card, int pinNumber, const u8 *pukValue, int pukL
|
|||
void msc_unblock_pin_apdu(sc_card_t *card, sc_apdu_t *apdu, u8* buffer, size_t bufferLength, int pinNumber, const u8 *pukValue, int pukLength)
|
||||
{
|
||||
assert(buffer);
|
||||
assert(bufferLength >= pukLength);
|
||||
assert(bufferLength >= (size_t)pukLength);
|
||||
assert(pukLength <= MSC_MAX_PIN_LENGTH);
|
||||
|
||||
truncatePinNulls(pukValue, &pukLength);
|
||||
|
@ -406,7 +406,7 @@ void msc_change_pin_apdu(sc_card_t *card, sc_apdu_t *apdu, u8* buffer, size_t bu
|
|||
assert(pinLength <= MSC_MAX_PIN_LENGTH);
|
||||
assert(newPinLength <= MSC_MAX_PIN_LENGTH);
|
||||
assert(buffer);
|
||||
assert(bufferLength >= pinLength + newPinLength + 2);
|
||||
assert(bufferLength >= pinLength + newPinLength + 2UL);
|
||||
|
||||
truncatePinNulls(pinValue, &pinLength);
|
||||
truncatePinNulls(newPin, &newPinLength);
|
||||
|
@ -806,7 +806,7 @@ int msc_compute_crypt(sc_card_t *card,
|
|||
size_t dataLength,
|
||||
size_t outputDataLength)
|
||||
{
|
||||
int left = dataLength;
|
||||
size_t left = dataLength;
|
||||
const u8* inPtr = data;
|
||||
u8* outPtr = outputData;
|
||||
int toSend;
|
||||
|
|
|
@ -263,7 +263,7 @@ static int public_key_created(struct pkcs15_fw_data *fw_data,
|
|||
struct pkcs15_any_object **obj2)
|
||||
{
|
||||
int found = 0;
|
||||
int ii=0;
|
||||
unsigned int ii=0;
|
||||
|
||||
while(ii<num_objects && !found) {
|
||||
if (!fw_data->objects[ii]->p15_object) {
|
||||
|
|
|
@ -136,9 +136,9 @@ static CK_RV sc_pkcs11_openssl_md_final(sc_pkcs11_operation_t *op,
|
|||
CK_BYTE_PTR pDigest, CK_ULONG_PTR pulDigestLen)
|
||||
{
|
||||
EVP_MD_CTX *md_ctx = DIGEST_CTX(op);
|
||||
unsigned int len = *pulDigestLen;
|
||||
CK_ULONG len = *pulDigestLen;
|
||||
|
||||
if (len < EVP_MD_CTX_size(md_ctx)) {
|
||||
if (len < (CK_ULONG)EVP_MD_CTX_size(md_ctx)) {
|
||||
*pulDigestLen = EVP_MD_CTX_size(md_ctx);
|
||||
return CKR_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
|
|
@ -713,7 +713,7 @@ void print_slot_list(FILE *f, CK_SLOT_ID_PTR pSlotList, CK_ULONG ulCount)
|
|||
|
||||
void print_slot_info(FILE *f, CK_SLOT_INFO *info)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
enum_specs ck_flags[] = {
|
||||
{ CKF_TOKEN_PRESENT , "CKF_TOKEN_PRESENT " },
|
||||
{ CKF_REMOVABLE_DEVICE , "CKF_REMOVABLE_DEVICE " },
|
||||
|
@ -899,7 +899,7 @@ void print_attribute_list_req(FILE *f, CK_ATTRIBUTE_PTR pTemplate,
|
|||
|
||||
void print_session_info(FILE *f, CK_SESSION_INFO *info)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
enum_specs ck_flags[] = {
|
||||
{ CKF_RW_SESSION , "CKF_RW_SESSION " },
|
||||
{ CKF_SERIAL_SESSION , "CKF_SERIAL_SESSION " }
|
||||
|
|
|
@ -150,7 +150,7 @@ scconf_item *scconf_item_add(scconf_context * config, scconf_block * block, scco
|
|||
scconf_item_add_internal(&parser, type);
|
||||
switch (parser.current_item->type) {
|
||||
case SCCONF_ITEM_TYPE_COMMENT:
|
||||
parser.current_item->value.comment = strdup((char *) data);
|
||||
parser.current_item->value.comment = strdup((const char *) data);
|
||||
break;
|
||||
case SCCONF_ITEM_TYPE_BLOCK:
|
||||
if (!dst)
|
||||
|
|
|
@ -92,7 +92,7 @@ static void buf_finished(BUFHAN * bp)
|
|||
}
|
||||
}
|
||||
|
||||
static void buf_eat_till(BUFHAN * bp, char start, char *end)
|
||||
static void buf_eat_till(BUFHAN * bp, char start, const char *end)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ int ask_and_verify_pin_code(struct sc_pkcs15_card *p15card,
|
|||
struct sc_pkcs15_object *pin)
|
||||
{
|
||||
int r;
|
||||
size_t len;
|
||||
const char *argv[3];
|
||||
const char *pgmname = PIN_ENTRY;
|
||||
ASSUAN_CONTEXT ctx;
|
||||
|
@ -78,12 +79,12 @@ int ask_and_verify_pin_code(struct sc_pkcs15_card *p15card,
|
|||
printf("GETPIN: %s\n", assuan_strerror((AssuanError) r));
|
||||
goto err;
|
||||
}
|
||||
r = strlen(buf);
|
||||
if (r < pinfo->min_length) {
|
||||
len = strlen(buf);
|
||||
if (len < pinfo->min_length) {
|
||||
sprintf(errtext, "PIN code too short, min. %lu digits", (unsigned long) pinfo->min_length);
|
||||
continue;
|
||||
}
|
||||
if (r > pinfo->max_length) {
|
||||
if (len > pinfo->max_length) {
|
||||
sprintf(errtext, "PIN code too long, max. %lu digits", (unsigned long) pinfo->max_length);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ struct sc_priv_data
|
|||
int ref_count, reader_id;
|
||||
};
|
||||
|
||||
extern RSA_METHOD * sc_get_method();
|
||||
extern RSA_METHOD * sc_get_method(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -95,6 +95,7 @@ static void print_pin(const struct sc_pkcs15_object *obj)
|
|||
static void print_prkey(const struct sc_pkcs15_object *obj)
|
||||
{
|
||||
int i;
|
||||
size_t j;
|
||||
const char *usages[] =
|
||||
{
|
||||
"encrypt", "decrypt", "sign", "signRecover",
|
||||
|
@ -131,8 +132,8 @@ static void print_prkey(const struct sc_pkcs15_object *obj)
|
|||
printf("\tNative : %s\n", prkey->native ? "yes" : "no");
|
||||
if (prkey->path.len) {
|
||||
printf("\tPath : ");
|
||||
for (i = 0; i < prkey->path.len; i++)
|
||||
printf("%02X", prkey->path.value[i]);
|
||||
for (j = 0; j < prkey->path.len; j++)
|
||||
printf("%02X", prkey->path.value[j]);
|
||||
if (prkey->path.type == SC_PATH_TYPE_PATH_PROT)
|
||||
printf(" (protected)");
|
||||
printf("\n");
|
||||
|
@ -143,6 +144,7 @@ static void print_prkey(const struct sc_pkcs15_object *obj)
|
|||
static void print_pubkey(const struct sc_pkcs15_object *obj)
|
||||
{
|
||||
int i;
|
||||
size_t j;
|
||||
const char *usages[] =
|
||||
{
|
||||
"encrypt", "decrypt", "sign", "signRecover",
|
||||
|
@ -178,8 +180,8 @@ static void print_pubkey(const struct sc_pkcs15_object *obj)
|
|||
printf("\tKey ref : %d\n", pubkey->key_reference);
|
||||
printf("\tNative : %s\n", pubkey->native ? "yes" : "no");
|
||||
printf("\tPath : ");
|
||||
for (i = 0; i < pubkey->path.len; i++)
|
||||
printf("%02X", pubkey->path.value[i]);
|
||||
for (j = 0; j < pubkey->path.len; j++)
|
||||
printf("%02X", pubkey->path.value[j]);
|
||||
printf("\n");
|
||||
printf("\tID : %s\n", sc_pkcs15_print_id(&pubkey->id));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ struct sc_pkcs15_card;
|
|||
struct sc_pkcs15_object;
|
||||
|
||||
int sc_test_init(int *argc, char *argv[]);
|
||||
void sc_test_cleanup();
|
||||
void sc_test_cleanup(void);
|
||||
void sc_test_print_card(const sc_pkcs15_card_t *);
|
||||
void sc_test_print_object(const struct sc_pkcs15_object *);
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ static int arg_to_path(const char *arg, sc_path_t *path, int is_id)
|
|||
path->type = SC_PATH_TYPE_DF_NAME;
|
||||
} else {
|
||||
/* file id */
|
||||
int buf[2];
|
||||
unsigned int buf[2];
|
||||
u8 cbuf[2];
|
||||
|
||||
if (strlen(arg) != 4) {
|
||||
|
@ -534,7 +534,7 @@ static int do_create(int argc, char **argv)
|
|||
if (arg_to_path(argv[0], &path, 1) != 0)
|
||||
goto usage;
|
||||
/* %z isn't supported everywhere */
|
||||
if (sscanf(argv[1], "%d", &size) != 1)
|
||||
if (sscanf(argv[1], "%u", &size) != 1)
|
||||
goto usage;
|
||||
file = sc_file_new();
|
||||
file->id = (path.value[0] << 8) | path.value[1];
|
||||
|
@ -564,7 +564,7 @@ static int do_mkdir(int argc, char **argv)
|
|||
goto usage;
|
||||
if (arg_to_path(argv[0], &path, 1) != 0)
|
||||
goto usage;
|
||||
if (sscanf(argv[1], "%d", &size) != 1)
|
||||
if (sscanf(argv[1], "%u", &size) != 1)
|
||||
goto usage;
|
||||
file = sc_file_new();
|
||||
file->id = (path.value[0] << 8) | path.value[1];
|
||||
|
|
|
@ -121,7 +121,8 @@ static int load_cert(const char * cert_id, const char * cert_file,
|
|||
derlen = stat_buf.st_size;
|
||||
der = malloc(derlen);
|
||||
if (der == NULL) {
|
||||
printf("file %s is too big, %d\n", cert_file, derlen);
|
||||
printf("file %s is too big, %lu\n",
|
||||
cert_file, (unsigned long)derlen);
|
||||
return-1 ;
|
||||
}
|
||||
if (1 != fread(der, derlen, 1, fp)) {
|
||||
|
|
|
@ -107,7 +107,7 @@ static int do_read_certificate(const char *, const char *, X509 **);
|
|||
static void parse_commandline(int argc, char **argv);
|
||||
static void read_options_file(const char *);
|
||||
static void ossl_print_errors(void);
|
||||
static void set_userpin_ref();
|
||||
static void set_userpin_ref(void);
|
||||
|
||||
|
||||
enum {
|
||||
|
|
Loading…
Reference in New Issue