Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow `InputStreamStreamInput` array size validation where applicable #26692

Merged
merged 3 commits into from Sep 18, 2017

Conversation

Projects
None yet
4 participants
@s1monw
Copy link
Contributor

commented Sep 18, 2017

Today we can't validate the array length in InputStreamStreamInput since
we can't rely on InputStream.available yet in some situations we know
the size of the stream and can apply additional validation.

Allow `InputStreamStreamInput` array size validation where applicable
Today we can't validate the array length in `InputStreamStreamInput` since
we can't rely on `InputStream.available` yet in some situations we know
the size of the stream and can apply additional validation.
@nik9000
Copy link
Contributor

left a comment

Very nice.

@@ -28,9 +28,24 @@
public class InputStreamStreamInput extends StreamInput {

private final InputStream is;
private final long sizeLimit;

public InputStreamStreamInput(InputStream is) {

This comment has been minimized.

Copy link
@nik9000

nik9000 Sep 18, 2017

Contributor

Probably worth adding javadoc here too.

@@ -705,7 +705,8 @@ public Weight createNormalizedWeight(Query query, boolean needsScores) throws IO
if (binaryDocValues.advanceExact(docId)) {
BytesRef qbSource = binaryDocValues.binaryValue();
try (InputStream in = new ByteArrayInputStream(qbSource.bytes, qbSource.offset, qbSource.length)) {
try (StreamInput input = new NamedWriteableAwareStreamInput(new InputStreamStreamInput(in), registry)) {
try (StreamInput input = new NamedWriteableAwareStreamInput(new InputStreamStreamInput(in, qbSource.length),
registry)) {

This comment has been minimized.

Copy link
@nik9000

nik9000 Sep 18, 2017

Contributor

Can you change the line wrapping on this somehow? Like stick new InputStreamStreamInput on a new line and indent it? I think as is it'd break how I visually scan try-with-resources.

try (StreamInput input = new NamedWriteableAwareStreamInput(new InputStreamStreamInput(in, qbSource.length),
registry)) {
try (StreamInput input = new NamedWriteableAwareStreamInput(
new InputStreamStreamInput(in, qbSource.length), registry)) {

This comment has been minimized.

Copy link
@nik9000

nik9000 Sep 18, 2017

Contributor

Thanks!

@s1monw s1monw merged commit 9f97f90 into elastic:master Sep 18, 2017

1 of 2 checks passed

elasticsearch-ci Build started sha1 is merged.
Details
CLA Commit author is a member of Elasticsearch
Details

@s1monw s1monw deleted the s1monw:allow_input_stream_validation branch Sep 18, 2017

s1monw added a commit that referenced this pull request Sep 18, 2017

Allow `InputStreamStreamInput` array size validation where applicable (
…#26692)

Today we can't validate the array length in `InputStreamStreamInput` since
we can't rely on `InputStream.available` yet in some situations we know
the size of the stream and can apply additional validation.

s1monw added a commit that referenced this pull request Sep 18, 2017

Allow `InputStreamStreamInput` array size validation where applicable (
…#26692)

Today we can't validate the array length in `InputStreamStreamInput` since
we can't rely on `InputStream.available` yet in some situations we know
the size of the stream and can apply additional validation.

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Sep 19, 2017

Merge branch 'master' into move-pre-6.0-node-checkpoint
* master:
  added comment
  fix line length violation
  Moved the check to fetch phase. This basically means that we throw a better error message instead of an AOBE and not adding more restrictions.
  inner hits: Do not allow inner hits that use _source and have a non nested object field as parent
  Separate Painless Whitelist Loading from the Painless Definition (elastic#26540)
  convert more admin requests to writeable (elastic#26566)
  Handle release of 5.6.1
  Allow `InputStreamStreamInput` array size validation where applicable (elastic#26692)
  Update global checkpoint with permit after recovery

jasontedor added a commit to droberts195/elasticsearch that referenced this pull request Sep 19, 2017

Merge branch 'master' into pr/26166
* master: (278 commits)
  Move pre-6.0 node checkpoint to SequenceNumbers
  Invalid JSON request body caused endless loop (elastic#26680)
  added comment
  fix line length violation
  Moved the check to fetch phase. This basically means that we throw a better error message instead of an AOBE and not adding more restrictions.
  inner hits: Do not allow inner hits that use _source and have a non nested object field as parent
  Separate Painless Whitelist Loading from the Painless Definition (elastic#26540)
  convert more admin requests to writeable (elastic#26566)
  Handle release of 5.6.1
  Allow `InputStreamStreamInput` array size validation where applicable (elastic#26692)
  Update global checkpoint with permit after recovery
  Filter pre-6.0 nodes for checkpoint invariants
  Skip bad request REST test on pre-6.0
  Reenable BWC tests after disabling for backport
  Add global checkpoint tracking on the primary
  [Test] Fix reference/cat/allocation/line_8 test failure
  [Docs] improved description for fs.total.available_in_bytes (elastic#26657)
  Fix discovery-file plugin to use custom config path
  fix testSniffNodes to use the new error message
  Add check for invalid index in WildcardExpressionResolver (elastic#26409)
  ...

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Sep 20, 2017

Merge branch 'master' into global-checkpoint-sync
* master: (67 commits)
  Restoring from snapshot should force generation of a new history uuid (elastic#26694)
  test: Use a single primary shard so that the exception can caught in the same way
  Move pre-6.0 node checkpoint to SequenceNumbers
  Invalid JSON request body caused endless loop (elastic#26680)
  added comment
  fix line length violation
  Moved the check to fetch phase. This basically means that we throw a better error message instead of an AOBE and not adding more restrictions.
  inner hits: Do not allow inner hits that use _source and have a non nested object field as parent
  Separate Painless Whitelist Loading from the Painless Definition (elastic#26540)
  convert more admin requests to writeable (elastic#26566)
  Handle release of 5.6.1
  Allow `InputStreamStreamInput` array size validation where applicable (elastic#26692)
  Update global checkpoint with permit after recovery
  Filter pre-6.0 nodes for checkpoint invariants
  Skip bad request REST test on pre-6.0
  Reenable BWC tests after disabling for backport
  Add global checkpoint tracking on the primary
  [Test] Fix reference/cat/allocation/line_8 test failure
  [Docs] improved description for fs.total.available_in_bytes (elastic#26657)
  Fix discovery-file plugin to use custom config path
  ...

@colings86 colings86 added v6.0.0-rc1 and removed v6.0.0 labels Sep 22, 2017

@lcawl lcawl removed the v6.1.0 label Dec 12, 2017

@colings86 colings86 added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.