diff options
author | Jake Farrell <jfarrell@apache.org> | 2012-03-22 02:40:45 +0000 |
---|---|---|
committer | Jake Farrell <jfarrell@apache.org> | 2012-03-22 02:40:45 +0000 |
commit | 9c6773aeef8ae25444bf9b4830edfe80b2e9aa7e (patch) | |
tree | 477a8afff62eff178adefe77240c9f1b570d0790 /lib | |
parent | 17515db9349fef971f9ae4e6f104894fdd4d9694 (diff) | |
download | thrift-9c6773aeef8ae25444bf9b4830edfe80b2e9aa7e.tar.gz |
THRIFT-1537:TFramedTransport issues
Client: delphi
Patch: Jens Geyer
TFramedTransport fixes for:
- The offset "off" is ignored, instead always 0 is used fpor reads and writes
- Trying to write an empty byte array results in range check exceptions
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1303637 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'lib')
-rw-r--r-- | lib/delphi/src/Thrift.Protocol.pas | 6 | ||||
-rw-r--r-- | lib/delphi/src/Thrift.Transport.pas | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index 82c58b1ab..a54008f2f 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -972,9 +972,11 @@ begin end;
procedure TBinaryProtocolImpl.WriteBinary( const b: TBytes);
+var iLen : Integer;
begin
- WriteI32( Length(b));
- FTrans.Write(b, 0, Length( b));
+ iLen := Length(b);
+ WriteI32( iLen);
+ if iLen > 0 then FTrans.Write(b, 0, iLen);
end;
procedure TBinaryProtocolImpl.WriteBool(b: Boolean);
diff --git a/lib/delphi/src/Thrift.Transport.pas b/lib/delphi/src/Thrift.Transport.pas index f5ccf6e31..8464e352f 100644 --- a/lib/delphi/src/Thrift.Transport.pas +++ b/lib/delphi/src/Thrift.Transport.pas @@ -1136,7 +1136,9 @@ var begin
if FReadBuffer <> nil then
begin
- got := FReadBuffer.Read( Pointer(@buf[0])^, len );
+ if len > 0
+ then got := FReadBuffer.Read( Pointer(@buf[off])^, len )
+ else got := 0;
if got > 0 then
begin
Result := got;
@@ -1145,7 +1147,9 @@ begin end;
ReadFrame;
- Result := FReadBuffer.Read( Pointer(@buf[0])^, len );
+ if len > 0
+ then Result := FReadBuffer.Read( Pointer(@buf[off])^, len)
+ else Result := 0;
end;
procedure TFramedTransportImpl.ReadFrame;
@@ -1171,7 +1175,8 @@ end; procedure TFramedTransportImpl.Write(const buf: TBytes; off, len: Integer);
begin
- FWriteBuffer.Write( Pointer(@buf[0])^, len );
+ if len > 0
+ then FWriteBuffer.Write( Pointer(@buf[off])^, len );
end;
{ TFramedTransport.TFactory }
|