Merge pull request #10 from aaronjense/fix-out-of-bounds-check
out of bounds check changed from using len(bytes to be hashes) to bufSz(size of array)pull/9/merge
commit
c49a62d42f
|
@ -109,8 +109,9 @@ Java_com_wolfssl_wolfcrypt_Md5_native_1update___3BII(
|
||||||
JNIEnv* env, jobject this, jbyteArray data_buffer, jint offset, jint len)
|
JNIEnv* env, jobject this, jbyteArray data_buffer, jint offset, jint len)
|
||||||
{
|
{
|
||||||
#ifndef NO_MD5
|
#ifndef NO_MD5
|
||||||
Md5* md5 = NULL;
|
Md5* md5 = NULL;
|
||||||
byte* data = NULL;
|
byte* data = NULL;
|
||||||
|
jsize bufSz = (*env)->GetArrayLength(env, data_buffer);
|
||||||
|
|
||||||
md5 = (Md5*) getNativeStruct(env, this);
|
md5 = (Md5*) getNativeStruct(env, this);
|
||||||
if ((*env)->ExceptionOccurred(env)) {
|
if ((*env)->ExceptionOccurred(env)) {
|
||||||
|
@ -120,7 +121,7 @@ Java_com_wolfssl_wolfcrypt_Md5_native_1update___3BII(
|
||||||
|
|
||||||
data = getByteArray(env, data_buffer);
|
data = getByteArray(env, data_buffer);
|
||||||
|
|
||||||
if (!md5 || !data || (offset > len)) {
|
if (!md5 || !data || (offset > bufSz)) {
|
||||||
throwWolfCryptExceptionFromError(env, BAD_FUNC_ARG);
|
throwWolfCryptExceptionFromError(env, BAD_FUNC_ARG);
|
||||||
} else {
|
} else {
|
||||||
wc_Md5Update(md5, data + offset, len);
|
wc_Md5Update(md5, data + offset, len);
|
||||||
|
|
Loading…
Reference in New Issue