mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
fix(java): validate decoder push length in Wrapper only
Per review feedback, keep the input length upper-bound check in DecoderJNI.Wrapper.push() and remove the redundant native guard.
This commit is contained in:
@@ -24,7 +24,6 @@ typedef struct DecoderHandle {
|
||||
size_t dictionary_count;
|
||||
|
||||
uint8_t* input_start;
|
||||
size_t input_size;
|
||||
size_t input_offset;
|
||||
size_t input_length;
|
||||
} DecoderHandle;
|
||||
@@ -68,7 +67,6 @@ JNIEXPORT jobject JNICALL Java_org_brotli_wrapper_dec_DecoderJNI_nativeCreate(
|
||||
handle->dictionary_count = 0;
|
||||
handle->input_offset = 0;
|
||||
handle->input_length = 0;
|
||||
handle->input_size = 0;
|
||||
handle->input_start = nullptr;
|
||||
|
||||
if (input_size == 0) {
|
||||
@@ -76,9 +74,6 @@ JNIEXPORT jobject JNICALL Java_org_brotli_wrapper_dec_DecoderJNI_nativeCreate(
|
||||
} else {
|
||||
handle->input_start = new (std::nothrow) uint8_t[input_size];
|
||||
ok = !!handle->input_start;
|
||||
if (ok) {
|
||||
handle->input_size = input_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,11 +125,6 @@ JNIEXPORT void JNICALL Java_org_brotli_wrapper_dec_DecoderJNI_nativePush(
|
||||
env->functions->SetLongArrayRegion(env, ctx, 0, 3, context);
|
||||
|
||||
if (input_length != 0) {
|
||||
/* Reject input length that exceeds the allocated input buffer. */
|
||||
if (input_length < 0 ||
|
||||
static_cast<size_t>(input_length) > handle->input_size) {
|
||||
return;
|
||||
}
|
||||
/* Still have unconsumed data. Workflow is broken. */
|
||||
if (handle->input_offset < handle->input_length) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user