diff options
author | Jens Geyer <jensg@apache.org> | 2022-09-03 14:19:31 +0200 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2022-09-04 00:07:35 +0200 |
commit | 73f5bd4315bed33b6e3a24b6479305002aebeb24 (patch) | |
tree | 3aa9ace8929d9bf41afc6b32f52bce6afb782483 | |
parent | 683263de0c76f133fb2dc7824775440fa6ad65fd (diff) | |
download | thrift-73f5bd4315bed33b6e3a24b6479305002aebeb24.tar.gz |
THRIFT-5619 make sure CheckReadBytesAvailable() and CountConsumedMessageBytes() handle negative sizes properly
Client: delphi
Patch: Jens Geyer
-rw-r--r-- | lib/delphi/src/Thrift.Transport.pas | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/delphi/src/Thrift.Transport.pas b/lib/delphi/src/Thrift.Transport.pas index 3f22b096a..fd088375d 100644 --- a/lib/delphi/src/Thrift.Transport.pas +++ b/lib/delphi/src/Thrift.Transport.pas @@ -596,7 +596,7 @@ end; procedure TEndpointTransportBase.CheckReadBytesAvailable( const numBytes : Int64); // Throws if there are not enough bytes in the input stream to satisfy a read of numBytes bytes of data begin - if RemainingMessageSize < numBytes + if (RemainingMessageSize < numBytes) or (numBytes < 0) then raise TTransportExceptionEndOfFile.Create('MaxMessageSize reached'); end; @@ -604,7 +604,7 @@ end; procedure TEndpointTransportBase.CountConsumedMessageBytes( const numBytes : Int64); // Consumes numBytes from the RemainingMessageSize. begin - if (RemainingMessageSize >= numBytes) + if (RemainingMessageSize >= numBytes) and (numBytes >= 0) then Dec( FRemainingMessageSize, numBytes) else begin FRemainingMessageSize := 0; |