[pkg-opensc-commit] [libp11] 24/67: Fix most gcc/msvc compiler warnings
Eric Dorland
eric at moszumanska.debian.org
Sat Jan 30 05:34:14 UTC 2016
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libp11.
commit 87fa165ed17f1432ca0298083ad1761aed7b3f81
Author: Michał Trojnara <Michal.Trojnara at mirt.net>
Date: Wed Dec 30 10:37:35 2015 +0100
Fix most gcc/msvc compiler warnings
---
.travis.yml | 2 +-
examples/auth.c | 3 ++-
examples/decrypt.c | 3 ++-
examples/rawrsasign.c | 3 ++-
src/libp11.h | 4 ++++
src/p11_ec.c | 7 +++----
src/p11_key.c | 6 ++----
src/p11_load.c | 6 +++---
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 8bff2b3..5c5cf31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,7 @@ before_script:
- sudo apt-add-repository -y ppa:pkg-opendnssec/ppa
- sudo apt-get update -qq
- sudo apt-get install -y softhsm libsofthsm-dev opensc
- - touch config.rpath && autoreconf -fvi && ./configure
+ - touch config.rpath && autoreconf -fvi && ./configure --enable-strict --enable-pedantic
script: make && make check && make dist
diff --git a/examples/auth.c b/examples/auth.c
index 53132ce..b4bc3c0 100644
--- a/examples/auth.c
+++ b/examples/auth.c
@@ -94,7 +94,8 @@ int main(int argc, char *argv[])
/* Read the password. */
printf("Password for token %.32s: ", slot->token->label);
- fgets(password, sizeof(password), stdin);
+ if (!fgets(password, sizeof(password), stdin))
+ goto failed;
/* Restore terminal. */
(void)tcsetattr(0, TCSAFLUSH, &old);
diff --git a/examples/decrypt.c b/examples/decrypt.c
index 16745a4..550ab46 100644
--- a/examples/decrypt.c
+++ b/examples/decrypt.c
@@ -157,7 +157,8 @@ int main(int argc, char *argv[])
/* Read the password. */
printf("Password for token %.32s: ", slot->token->label);
- fgets(password, sizeof(password), stdin);
+ if (!fgets(password, sizeof(password), stdin))
+ goto failed;
/* Restore terminal. */
(void)tcsetattr(0, TCSAFLUSH, &old);
diff --git a/examples/rawrsasign.c b/examples/rawrsasign.c
index 74e9faf..72c3491 100644
--- a/examples/rawrsasign.c
+++ b/examples/rawrsasign.c
@@ -123,7 +123,8 @@ int main(int argc, char *argv[])
/* Read the password. */
printf("Password for token %.32s: ", slot->token->label);
- fgets(password, sizeof(password), stdin);
+ if (!fgets(password, sizeof(password), stdin))
+ END(1);
/* Restore terminal. */
(void)tcsetattr(0, TCSAFLUSH, &old);
diff --git a/src/libp11.h b/src/libp11.h
index 574719c..355c6fd 100644
--- a/src/libp11.h
+++ b/src/libp11.h
@@ -375,6 +375,10 @@ extern int PKCS11_store_certificate(PKCS11_TOKEN * token, X509 * x509,
char *label, unsigned char *id, size_t id_len,
PKCS11_CERT **ret_cert);
+/* ec private key operations */
+extern int PKCS11_ecdsa_sign(const unsigned char *m, unsigned int m_len,
+ unsigned char *sigret, unsigned int *siglen, PKCS11_KEY * key);
+
/* rsa private key operations */
extern int PKCS11_sign(int type, const unsigned char *m, unsigned int m_len,
unsigned char *sigret, unsigned int *siglen, PKCS11_KEY * key);
diff --git a/src/p11_ec.c b/src/p11_ec.c
index e01795c..f298da9 100644
--- a/src/p11_ec.c
+++ b/src/p11_ec.c
@@ -103,7 +103,6 @@ static int pkcs11_get_ec_private(PKCS11_KEY * key, EVP_PKEY * pk)
CK_BBOOL sensitive, extractable;
EC_KEY * ec = NULL;
CK_RV ckrv;
- int rv;
size_t ec_paramslen = 0;
CK_BYTE * ec_params = NULL;
size_t ec_pointlen = 0;
@@ -228,7 +227,7 @@ static ECDSA_SIG * pkcs11_ecdsa_do_sign(const unsigned char *dgst, int dlen,
unsigned char sigret[512]; /* HACK for now */
ECDSA_SIG * sig = NULL;
PKCS11_KEY * key = NULL;
- int siglen;
+ unsigned int siglen;
int nLen = 48; /* HACK */
int rv;
@@ -238,7 +237,7 @@ static ECDSA_SIG * pkcs11_ecdsa_do_sign(const unsigned char *dgst, int dlen,
siglen = sizeof(sigret);
- rv = PKCS11_ecdsa_sign(dgst,dlen,sigret,&siglen, key);
+ rv = PKCS11_ecdsa_sign(dgst, dlen, sigret, &siglen, key);
nLen = siglen / 2;
if (rv > 0) {
sig = ECDSA_SIG_new();
@@ -262,7 +261,7 @@ ECDSA_METHOD *PKCS11_get_ecdsa_method(void)
{
if (ops == NULL) {
- ops = ECDSA_METHOD_new(ECDSA_OpenSSL());
+ ops = ECDSA_METHOD_new((ECDSA_METHOD *)ECDSA_OpenSSL());
ECDSA_METHOD_set_sign(ops, pkcs11_ecdsa_do_sign);
ECDSA_METHOD_set_sign_setup(ops, pkcs11_ecdsa_sign_setup);
}
diff --git a/src/p11_key.c b/src/p11_key.c
index dba1480..416a438 100644
--- a/src/p11_key.c
+++ b/src/p11_key.c
@@ -123,9 +123,7 @@ int pkcs11_reload_keys(PKCS11_KEY * keyin)
{
PKCS11_TOKEN_private *tpriv;
PKCS11_KEY_private *kinpriv;
- PKCS11_KEY *key;
- unsigned int n;
- long int count;
+ unsigned long count, n;
CK_OBJECT_CLASS kclass = CKO_PRIVATE_KEY;
CK_ATTRIBUTE attrs[2];
int rv;
@@ -140,7 +138,7 @@ int pkcs11_reload_keys(PKCS11_KEY * keyin)
/* We want to use all the keys, the above only returns count for private */
count = tpriv->nkeys;
- for (n = 0; n < count; n++, key++) {
+ for (n = 0; n < count; n++) {
attrs[0].type = CKA_CLASS;
attrs[0].pValue = &kclass;
attrs[0].ulValueLen = sizeof(kclass);
diff --git a/src/p11_load.c b/src/p11_load.c
index f2a65ff..eb3badc 100644
--- a/src/p11_load.c
+++ b/src/p11_load.c
@@ -57,9 +57,9 @@ void PKCS11_CTX_init_args(PKCS11_CTX * ctx, const char *init_args)
PKCS11_CTX_private *priv = PRIVCTX(ctx);
/* Free previously duplicated string */
if (priv->init_args) {
- free(priv->init_args);
+ OPENSSL_free(priv->init_args);
}
- priv->init_args = init_args ? strdup(init_args) : NULL;
+ priv->init_args = init_args ? BUF_strdup(init_args) : NULL;
}
/*
@@ -162,7 +162,7 @@ void PKCS11_CTX_free(PKCS11_CTX * ctx)
ERR_remove_state(0);
*/
if (priv->init_args) {
- free(priv->init_args);
+ OPENSSL_free(priv->init_args);
}
OPENSSL_free(ctx->manufacturer);
OPENSSL_free(ctx->description);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/libp11.git
More information about the pkg-opensc-commit
mailing list