aboutsummaryrefslogtreecommitdiff
path: root/src/share/native/sun
diff options
context:
space:
mode:
authorvinnie <none@none>2014-10-03 14:50:02 +0100
committervinnie <none@none>2014-10-03 14:50:02 +0100
commit417f0ee73bd694ebd83c679ebab39e9ac76881c6 (patch)
tree0f66793a5e6fd0ec1bdccf7eb1c4c097b128b0c9 /src/share/native/sun
parent2b45ac5e4690afdc4d647182222fa8e0e7c0505e (diff)
8028727: [parfait] warnings from b116 for jdk.src.share.native.sun.security.ec: JNI pending exceptions
Reviewed-by: alanb
Diffstat (limited to 'src/share/native/sun')
-rw-r--r--src/share/native/sun/security/ec/ECC_JNI.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/share/native/sun/security/ec/ECC_JNI.cpp b/src/share/native/sun/security/ec/ECC_JNI.cpp
index f2612adc2..684f82eac 100644
--- a/src/share/native/sun/security/ec/ECC_JNI.cpp
+++ b/src/share/native/sun/security/ec/ECC_JNI.cpp
@@ -41,7 +41,9 @@ extern "C" {
void ThrowException(JNIEnv *env, const char *exceptionName)
{
jclass exceptionClazz = env->FindClass(exceptionName);
- env->ThrowNew(exceptionClazz, NULL);
+ if (exceptionClazz != NULL) {
+ env->ThrowNew(exceptionClazz, NULL);
+ }
}
/*
@@ -80,7 +82,6 @@ jbyteArray getEncodedBytes(JNIEnv *env, SECItem *hSECItem)
return jEncodedBytes;
}
-
/*
* Class: sun_security_ec_ECKeyPairGenerator
* Method: generateECKeyPair
@@ -103,6 +104,9 @@ JNICALL Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair
params_item.len = env->GetArrayLength(encodedParams);
params_item.data =
(unsigned char *) env->GetByteArrayElements(encodedParams, 0);
+ if (params_item.data == NULL) {
+ goto cleanup;
+ }
// Fill a new ECParams using the supplied OID
if (EC_DecodeParams(&params_item, &ecparams, 0) != SECSuccess) {
@@ -170,6 +174,7 @@ cleanup:
SECITEM_FreeItem(&privKey->publicValue, B_FALSE);
free(privKey);
}
+
if (pSeedBuffer) {
delete [] pSeedBuffer;
}
@@ -213,6 +218,9 @@ JNICALL Java_sun_security_ec_ECDSASignature_signDigest
params_item.len = env->GetArrayLength(encodedParams);
params_item.data =
(unsigned char *) env->GetByteArrayElements(encodedParams, 0);
+ if (params_item.data == NULL) {
+ goto cleanup;
+ }
// Fill a new ECParams using the supplied OID
if (EC_DecodeParams(&params_item, &ecparams, 0) != SECSuccess) {
@@ -226,6 +234,9 @@ JNICALL Java_sun_security_ec_ECDSASignature_signDigest
privKey.privateValue.len = env->GetArrayLength(privateKey);
privKey.privateValue.data =
(unsigned char *) env->GetByteArrayElements(privateKey, 0);
+ if (privKey.privateValue.data == NULL) {
+ goto cleanup;
+ }
// Prepare a buffer for the signature (twice the key length)
pSignedDigestBuffer = new jbyte[ecparams->order.len * 2];
@@ -245,6 +256,9 @@ JNICALL Java_sun_security_ec_ECDSASignature_signDigest
// Create new byte array
temp = env->NewByteArray(signature_item.len);
+ if (temp == NULL) {
+ goto cleanup;
+ }
// Copy data from native buffer
env->SetByteArrayRegion(temp, 0, signature_item.len, pSignedDigestBuffer);
@@ -317,6 +331,9 @@ JNICALL Java_sun_security_ec_ECDSASignature_verifySignedDigest
params_item.len = env->GetArrayLength(encodedParams);
params_item.data =
(unsigned char *) env->GetByteArrayElements(encodedParams, 0);
+ if (params_item.data == NULL) {
+ goto cleanup;
+ }
// Fill a new ECParams using the supplied OID
if (EC_DecodeParams(&params_item, &ecparams, 0) != SECSuccess) {
@@ -369,25 +386,34 @@ JNICALL Java_sun_security_ec_ECDHKeyAgreement_deriveKey
(JNIEnv *env, jclass clazz, jbyteArray privateKey, jbyteArray publicKey, jbyteArray encodedParams)
{
jbyteArray jSecret = NULL;
+ ECParams *ecparams = NULL;
// Extract private key value
SECItem privateValue_item;
privateValue_item.len = env->GetArrayLength(privateKey);
privateValue_item.data =
(unsigned char *) env->GetByteArrayElements(privateKey, 0);
+ if (privateValue_item.data == NULL) {
+ goto cleanup;
+ }
// Extract public key value
SECItem publicValue_item;
publicValue_item.len = env->GetArrayLength(publicKey);
publicValue_item.data =
(unsigned char *) env->GetByteArrayElements(publicKey, 0);
+ if (publicValue_item.data == NULL) {
+ goto cleanup;
+ }
// Initialize the ECParams struct
- ECParams *ecparams = NULL;
SECKEYECParams params_item;
params_item.len = env->GetArrayLength(encodedParams);
params_item.data =
(unsigned char *) env->GetByteArrayElements(encodedParams, 0);
+ if (params_item.data == NULL) {
+ goto cleanup;
+ }
// Fill a new ECParams using the supplied OID
if (EC_DecodeParams(&params_item, &ecparams, 0) != SECSuccess) {
@@ -409,6 +435,9 @@ JNICALL Java_sun_security_ec_ECDHKeyAgreement_deriveKey
// Create new byte array
jSecret = env->NewByteArray(secret_item.len);
+ if (jSecret == NULL) {
+ goto cleanup;
+ }
// Copy bytes from the SECItem buffer to a Java byte array
env->SetByteArrayRegion(jSecret, 0, secret_item.len,