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

BufferOverflowException in SocketChannelOutputBuffer #23

Closed
arinban opened this issue Sep 18, 2007 · 13 comments
Closed

BufferOverflowException in SocketChannelOutputBuffer #23

arinban opened this issue Sep 18, 2007 · 13 comments

Comments

@arinban
Copy link

arinban commented Sep 18, 2007

public void realWriteBytes(byte cbuf[], int off, int len)
throws IOException {
if (len > 0) {
if (len > outputByteBuffer.remaining())

{ ByteBuffer tmp = ByteBuffer.allocate( outputByteBuffer.capacity() * 2 + len); outputByteBuffer.flip(); tmp.put(outputByteBuffer); outputByteBuffer = tmp; }

outputByteBuffer.put(cbuf, off, len);
}
}

if position + len is bigger than capacity * 2, outputByteBuffer overflows.

Environment

Operating System: All
Platform: All

Affected Versions

[1.9.22]

@arinban
Copy link
Author

arinban commented Sep 18, 2007

@glassfishrobot Commented
Reported by iasandcb@java.net

@arinban
Copy link
Author

arinban commented Sep 18, 2007

@glassfishrobot Commented
Was assigned to grizzly-issues

@arinban
Copy link
Author

arinban commented Sep 18, 2007

@glassfishrobot Commented
iasandcb@java.net said:
Created an attachment (id=3)
patch for this issue

@arinban
Copy link
Author

arinban commented Sep 18, 2007

@glassfishrobot Commented
File: ias-2007-09-17.patch
Attached By: iasandcb@java.net

@arinban
Copy link
Author

arinban commented Sep 18, 2007

@glassfishrobot Commented
iasandcb@java.net said:
Oops, sorry. The original code is
public void realWriteBytes(byte cbuf[], int off, int len)
throws IOException {
if (len > 0) {
if (len > outputByteBuffer.remaining())

{ ByteBuffer tmp = ByteBuffer.allocate( outputByteBuffer.capacity() * 2); outputByteBuffer.flip(); tmp.put(outputByteBuffer); outputByteBuffer = tmp; }

outputByteBuffer.put(cbuf, off, len);
}
}

@arinban
Copy link
Author

arinban commented Sep 18, 2007

@glassfishrobot Commented
jfarcand@java.net said:
Thanks! It was fixed in 1.0, but I forgot to port the fix.

@arinban
Copy link
Author

arinban commented Sep 18, 2007

@glassfishrobot Commented
jfarcand@java.net said:
What about the fix from 1.0:

public void realWriteBytes(byte cbuf[], int off, int len)
throws IOException {
if (len > 0) {
if (len > outputByteBuffer.remaining())

{ int size = Math.max(outputByteBuffer.capacity() * 2, len + outputByteBuffer.position()); ByteBuffer tmp = ByteBuffer.allocate(size); outputByteBuffer.flip(); tmp.put(outputByteBuffer); outputByteBuffer = tmp; }

outputByteBuffer.put(cbuf, off, len);
}
}

@arinban
Copy link
Author

arinban commented Sep 18, 2007

@glassfishrobot Commented
iasandcb@java.net said:
+1

@arinban
Copy link
Author

arinban commented Sep 19, 2007

@glassfishrobot Commented
jfarcand@java.net said:
Fixed. Thanks!!

[ja120114@localhost trunk]$ svn commit
Sending
trunk/modules/http/src/main/java/com/sun/grizzly/http/SocketChannelOutputBuffer.java
Transmitting file data .
Committed revision 510.

@arinban
Copy link
Author

arinban commented Jun 12, 2008

@glassfishrobot Commented
jfarcand@java.net said:
Fix milestones

@arinban
Copy link
Author

arinban commented Dec 17, 2009

@glassfishrobot Commented
Marked as fixed on Wednesday, December 16th 2009, 6:14:16 pm

@arinban arinban closed this as completed Dec 17, 2009
@arinban
Copy link
Author

arinban commented Apr 26, 2017

@glassfishrobot Commented
This issue was imported from java.net JIRA GRIZZLY-23

@arinban
Copy link
Author

arinban commented Feb 3, 2018

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

No branches or pull requests

1 participant