Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/transport/tcp
In directory usw-pr-cvs1:/tmp/cvs-serv6782/src/org/beepcore/beep/transport/tcp
Modified Files:
TCPSession.java
Log Message:
Fix for frames with small payloads
Index: TCPSession.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/transport/tcp/TCPSession.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** TCPSession.java 30 Apr 2002 17:09:35 -0000 1.22
--- TCPSession.java 2 May 2002 02:07:58 -0000 1.23
***************
*** 558,586 ****
int count = amountRead - headerLength;
! System.arraycopy(headerBuffer, headerLength, payload, 0, count);
! while (count < payload.length) {
! int n = is.read(payload, count, payload.length - count);
! if (n == -1) {
! throw new SessionAbortedException();
! }
! count += n;
! }
! if (Log.isLogged(Log.SEV_DEBUG_VERBOSE)) {
! Log.logEntry(Log.SEV_DEBUG_VERBOSE, TCP_MAPPING,
! new String(payload));
! }
! for (int i = 0; i < Frame.TRAILER.length(); ++i) {
! int b = is.read();
! if (b == -1) {
! throw new SessionAbortedException();
}
! if (((byte) b) != ((byte) Frame.TRAILER.charAt(i))) {
! throw new BEEPException("Malformed BEEP frame, "
! + "invalid trailer");
}
}
--- 558,611 ----
int count = amountRead - headerLength;
! if (count > payload.length) {
! System.arraycopy(headerBuffer, headerLength, payload, 0,
! payload.length);
! count -= payload.length;
!
! for (int i = 0; i < Frame.TRAILER.length(); ++i) {
! int b;
! if (count > 0) {
! b = headerBuffer[headerLength + payload.length + i];
! --count;
! } else {
! b = is.read();
! if (b == -1) {
! throw new SessionAbortedException();
! }
! }
! if (((byte) b) != ((byte) Frame.TRAILER.charAt(i))) {
! throw new BEEPException("Malformed BEEP frame, "
! + "invalid trailer");
! }
! }
! } else {
! System.arraycopy(headerBuffer, headerLength, payload, 0, count);
! while (count < payload.length) {
! int n = is.read(payload, count, payload.length - count);
! if (n == -1) {
! throw new SessionAbortedException();
! }
! count += n;
! }
! if (Log.isLogged(Log.SEV_DEBUG_VERBOSE)) {
! Log.logEntry(Log.SEV_DEBUG_VERBOSE, TCP_MAPPING,
! new String(payload));
}
! for (int i = 0; i < Frame.TRAILER.length(); ++i) {
! int b = is.read();
!
! if (b == -1) {
! throw new SessionAbortedException();
! }
!
! if (((byte) b) != ((byte) Frame.TRAILER.charAt(i))) {
! throw new BEEPException("Malformed BEEP frame, "
! + "invalid trailer");
! }
}
}
|