diff options
author | Kenny Root <kroot@google.com> | 2013-06-05 22:46:10 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-06-05 22:46:11 +0000 |
commit | aa1e1d6d989c7a659659f4fd20387cf67f11f64a (patch) | |
tree | 95ef4ff390542e60686c5d878f5f33c26d96286b /crypto/src | |
parent | a65d5826d30d42f59283e24047810a4b940335b4 (diff) | |
parent | adadc611f606e693ed30b2e495326cb32968153d (diff) | |
download | libcore-aa1e1d6d989c7a659659f4fd20387cf67f11f64a.zip libcore-aa1e1d6d989c7a659659f4fd20387cf67f11f64a.tar.gz libcore-aa1e1d6d989c7a659659f4fd20387cf67f11f64a.tar.bz2 |
Merge "NativeCrypto: handle X.509 serial number 0"
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/main/native/org_conscrypt_NativeCrypto.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/src/main/native/org_conscrypt_NativeCrypto.cpp b/crypto/src/main/native/org_conscrypt_NativeCrypto.cpp index 9fff02c..62eda3e 100644 --- a/crypto/src/main/native/org_conscrypt_NativeCrypto.cpp +++ b/crypto/src/main/native/org_conscrypt_NativeCrypto.cpp @@ -752,8 +752,7 @@ static jbyteArray bignumToArray(JNIEnv* env, const BIGNUM* source, const char* s return NULL; } - int len = BN_num_bytes(source) + 1; - jbyteArray javaBytes = env->NewByteArray(len); + jbyteArray javaBytes = env->NewByteArray(BN_num_bytes(source) + 1); ScopedByteArrayRW bytes(env, javaBytes); if (bytes.get() == NULL) { JNI_TRACE("bignumToArray(%p, %s) => NULL", source, sourceName); @@ -769,7 +768,7 @@ static jbyteArray bignumToArray(JNIEnv* env, const BIGNUM* source, const char* s *tmp = 0x00; } - if (BN_bn2bin(source, tmp + 1) <= 0) { + if (BN_num_bytes(source) > 0 && BN_bn2bin(source, tmp + 1) <= 0) { throwExceptionIfNecessary(env, "bignumToArray"); return NULL; } |