diff options
author | Toomas Soome <tsoome@me.com> | 2019-01-22 15:32:31 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2019-07-03 23:47:52 +0300 |
commit | f810c7e5159aec14e1937d86287a006e755d3d99 (patch) | |
tree | e8117907430a5039b6dfc52c5b3cb0492ce05250 | |
parent | 67d74cc3e7c9d9461311136a0b2069813a3fd927 (diff) | |
download | illumos-gate-f810c7e5159aec14e1937d86287a006e755d3d99.tar.gz |
11164 libkmf: NULL pointer errors
Reviewed by: C Fraire <cfraire@me.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r-- | usr/src/lib/libkmf/libkmf/common/certgetsetop.c | 4 | ||||
-rw-r--r-- | usr/src/lib/libkmf/libkmf/common/certop.c | 2 | ||||
-rw-r--r-- | usr/src/lib/libkmf/libkmf/common/generalop.c | 4 | ||||
-rw-r--r-- | usr/src/lib/libkmf/libkmf/common/pk11keys.c | 4 | ||||
-rw-r--r-- | usr/src/lib/libkmf/libkmf/common/pk11tokens.c | 2 | ||||
-rw-r--r-- | usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c | 10 | ||||
-rw-r--r-- | usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c | 8 |
7 files changed, 17 insertions, 17 deletions
diff --git a/usr/src/lib/libkmf/libkmf/common/certgetsetop.c b/usr/src/lib/libkmf/libkmf/common/certgetsetop.c index 167df96507..f6acec95d6 100644 --- a/usr/src/lib/libkmf/libkmf/common/certgetsetop.c +++ b/usr/src/lib/libkmf/libkmf/common/certgetsetop.c @@ -1943,7 +1943,7 @@ kmf_set_cert_validity(KMF_X509_CERTIFICATE *CertData, return (KMF_ERR_BAD_PARAMETER); /* Set up validity fields */ - if (notBefore == NULL) + if (notBefore == 0) clock = time(NULL); else clock = notBefore; @@ -2002,7 +2002,7 @@ set_integer(KMF_DATA *data, void *value, int length) static KMF_RETURN set_bigint(KMF_BIGINT *data, KMF_BIGINT *bigint) { - if (data == NULL || bigint == NULL || bigint->len == NULL) + if (data == NULL || bigint == NULL || bigint->len == 0) return (KMF_ERR_BAD_PARAMETER); data->val = malloc(bigint->len); diff --git a/usr/src/lib/libkmf/libkmf/common/certop.c b/usr/src/lib/libkmf/libkmf/common/certop.c index 77cb1e949b..2bd06308ae 100644 --- a/usr/src/lib/libkmf/libkmf/common/certop.c +++ b/usr/src/lib/libkmf/libkmf/common/certop.c @@ -276,7 +276,7 @@ kmf_find_cert(KMF_HANDLE_T handle, int numattr, KMF_ATTRIBUTE *attrlist) return (plugin->funclist->FindCert(handle, numattr, attrlist)); } -#define NODATA(d) (d.Data == NULL || d.Length == NULL) +#define NODATA(d) (d.Data == NULL || d.Length == 0) KMF_RETURN kmf_encode_cert_record(KMF_X509_CERTIFICATE *CertData, KMF_DATA *encodedCert) diff --git a/usr/src/lib/libkmf/libkmf/common/generalop.c b/usr/src/lib/libkmf/libkmf/common/generalop.c index e29eaddf5d..fd52c64bbf 100644 --- a/usr/src/lib/libkmf/libkmf/common/generalop.c +++ b/usr/src/lib/libkmf/libkmf/common/generalop.c @@ -423,9 +423,9 @@ Cleanup_PK11_Session(KMF_HANDLE_T handle) { if (handle != NULL) { /* Close active session on a pkcs11 token */ - if (handle->pk11handle != NULL) { + if (handle->pk11handle != 0) { (void) C_CloseSession(handle->pk11handle); - handle->pk11handle = NULL; + handle->pk11handle = 0; } } } diff --git a/usr/src/lib/libkmf/libkmf/common/pk11keys.c b/usr/src/lib/libkmf/libkmf/common/pk11keys.c index 015cd8a14c..9aff2166c7 100644 --- a/usr/src/lib/libkmf/libkmf/common/pk11keys.c +++ b/usr/src/lib/libkmf/libkmf/common/pk11keys.c @@ -26,7 +26,7 @@ typedef struct } ALG_INFO; static const ALG_INFO alg_info_map[] = { - { KMF_ALGID_RSA, CKK_RSA, CKM_RSA_PKCS, CKM_RSA_PKCS, NULL}, + { KMF_ALGID_RSA, CKK_RSA, CKM_RSA_PKCS, CKM_RSA_PKCS, 0}, { KMF_ALGID_DSA, CKK_DSA, CKM_DSA, CKM_DSA, CKM_SHA_1 }, { KMF_ALGID_ECDSA, CKK_EC, CKM_ECDSA, CKM_ECDSA, CKM_SHA_1 }, { KMF_ALGID_SHA1WithDSA, CKK_DSA, CKM_DSA, CKM_DSA, CKM_SHA_1 }, @@ -554,7 +554,7 @@ PKCS_EncryptData(KMF_HANDLE_T kmfh, CK_MECHANISM_TYPE mechtype; CK_KEY_TYPE keytype; CK_OBJECT_HANDLE ckKeyHandle = 0; - CK_SESSION_HANDLE ckSession = NULL; + CK_SESSION_HANDLE ckSession = 0; CK_ULONG out_len = 0, in_len = 0, total_encrypted = 0; uint8_t *in_data, *out_data; int i, blocks, block_size; diff --git a/usr/src/lib/libkmf/libkmf/common/pk11tokens.c b/usr/src/lib/libkmf/libkmf/common/pk11tokens.c index a9cf513f29..c71bd73b4a 100644 --- a/usr/src/lib/libkmf/libkmf/common/pk11tokens.c +++ b/usr/src/lib/libkmf/libkmf/common/pk11tokens.c @@ -521,7 +521,7 @@ kmf_select_token(KMF_HANDLE_T handle, char *label, int readonly) } /* Only one token can be active per thread */ - if (handle->pk11handle != NULL) { + if (handle->pk11handle != 0) { return (KMF_ERR_TOKEN_SELECTED); } diff --git a/usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c b/usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c index f014d5b2be..f65274f7c2 100644 --- a/usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c +++ b/usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c @@ -818,7 +818,7 @@ readAltFormatPrivateKey(KMF_DATA *filedata, EVP_PKEY **pkey) KMF_RAW_RSA_KEY rsa; BerElement *asn1 = NULL; BerValue filebuf; - BerValue OID = { NULL, 0 }; + BerValue OID = { 0, 0 }; BerValue *Mod = NULL, *PubExp = NULL; BerValue *PriExp = NULL, *Prime1 = NULL, *Prime2 = NULL; BerValue *Coef = NULL; @@ -2635,7 +2635,7 @@ check_response_signature(KMF_HANDLE_T handle, OCSP_BASICRESP *bs, goto end; } - if (sk_X509_push(cert_stack, issuer) == NULL) { + if (sk_X509_push(cert_stack, issuer) == 0) { ret = KMF_ERR_INTERNAL; goto end; } @@ -3631,7 +3631,7 @@ OpenSSL_ExportPK12(KMF_HANDLE_T handle, int numattr, KMF_ATTRIBUTE *attrlist) } (void) memset(&certdata, 0, sizeof (certdata)); - rv = kmf_load_cert(kmfh, NULL, NULL, NULL, NULL, + rv = kmf_load_cert(kmfh, NULL, NULL, NULL, 0, fullpath, &certdata.certificate); if (rv != KMF_OK) goto end; @@ -3940,7 +3940,7 @@ openssl_parse_bag(PKCS12_SAFEBAG *bag, char *pass, int passlen, fname->value.asn1_string); if (len > 0 && data != NULL) { r = X509_alias_set1(xcert, data, len); - if (r == NULL) { + if (r == 0) { ret = KMF_ERR_PKCS12_FORMAT; goto end; } @@ -4026,7 +4026,7 @@ openssl_pkcs12_parse(PKCS12 *p12, char *pin, if (p12 == NULL || (keys == NULL && certs == NULL)) return (KMF_ERR_BAD_PARAMETER); - if (pin == NULL || *pin == NULL) { + if (pin == NULL || *pin == '\0') { if (PKCS12_verify_mac(p12, NULL, 0)) { pin = NULL; } else if (PKCS12_verify_mac(p12, "", 0)) { diff --git a/usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c b/usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c index bab6957c45..85f6b08b22 100644 --- a/usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c +++ b/usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c @@ -194,7 +194,7 @@ pk11_authenticate(KMF_HANDLE_T handle, CK_RV ck_rv = CKR_OK; CK_SESSION_HANDLE hSession = (CK_SESSION_HANDLE)handle->pk11handle; - if (hSession == NULL) + if (hSession == 0) return (KMF_ERR_NO_TOKEN_SELECTED); if (cred == NULL || cred->cred == NULL) { @@ -1104,7 +1104,7 @@ CreateCertObject(KMF_HANDLE_T handle, char *label, KMF_DATA *pcert) CK_CERTIFICATE_TYPE certtype = CKC_X_509; CK_OBJECT_CLASS certClass = CKO_CERTIFICATE; CK_ATTRIBUTE x509templ[11]; - CK_OBJECT_HANDLE hCert = NULL; + CK_OBJECT_HANDLE hCert = 0; int i; if (kmfh == NULL) @@ -3742,7 +3742,7 @@ KMFPK11_SetTokenPin(KMF_HANDLE_T handle, KMF_RETURN ret = KMF_OK; CK_RV rv = CKR_OK; KMF_HANDLE *kmfh = (KMF_HANDLE *)handle; - CK_SESSION_HANDLE session = NULL; + CK_SESSION_HANDLE session = 0; KMF_CREDENTIAL *oldcred; KMF_CREDENTIAL *newcred; CK_SLOT_ID slotid; @@ -3819,7 +3819,7 @@ KMFPK11_SetTokenPin(KMF_HANDLE_T handle, ret = KMF_ERR_INTERNAL; } end: - if (session != NULL) + if (session != 0) (void) C_CloseSession(session); return (ret); } |