Skip to content

Correctly take length of ByteBufInputStream into account for readLine…#9310

Merged
normanmaurer merged 2 commits into
4.1from
buffer_stream_limit
Jul 1, 2019
Merged

Correctly take length of ByteBufInputStream into account for readLine…#9310
normanmaurer merged 2 commits into
4.1from
buffer_stream_limit

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

…() / readByte()

Motivation:

ByteBufInputStream did not correctly take the length into account when validate bounds for readLine() / readByte() which could lead to read more then allowed.

Modifications:

  • Correctly take length into account
  • Add unit tests
  • Fix existing unit test

Result:

Correctly take length of ByteBufInputStream into account.
Related to #9306.

…() / readByte()

Motivation:

ByteBufInputStream did not correctly take the length into account when validate bounds for readLine() / readByte() which could lead to read more then allowed.

Modifications:

- Correctly take length into account
- Add unit tests
- Fix existing unit test

Result:

Correctly take length of ByteBufInputStream into account.
Related to #9306.
@normanmaurer
Copy link
Copy Markdown
Member Author

/cc @xiaoheng1 this is related to the issue you fixed .

@normanmaurer normanmaurer requested review from franz1981 and njhill July 1, 2019 14:20
Copy link
Copy Markdown
Contributor

@franz1981 franz1981 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic seems correct!

Comment thread buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java Outdated
@normanmaurer normanmaurer merged commit 131be58 into 4.1 Jul 1, 2019
@normanmaurer normanmaurer deleted the buffer_stream_limit branch July 1, 2019 18:55
@normanmaurer normanmaurer added this to the 4.1.38.Final milestone Jul 1, 2019
normanmaurer added a commit that referenced this pull request Jul 1, 2019
#9310)

* Correctly take length of ByteBufInputStream into account for readLine() / readByte()

Motivation:

ByteBufInputStream did not correctly take the length into account when validate bounds for readLine() / readByte() which could lead to read more then allowed.

Modifications:

- Correctly take length into account
- Add unit tests
- Fix existing unit test

Result:

Correctly take length of ByteBufInputStream into account.
Related to #9306.
Copy link
Copy Markdown
Member

@njhill njhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just an optional nit which I guess applies to the read() method too

public byte readByte() throws IOException {
if (!buffer.isReadable()) {
int available = available();
if (available == 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why separate var?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just because it was like this in other methods as well. So I felt it would be better to keep it consistent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants