summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2022-09-03 14:19:31 +0200
committerJens Geyer <jensg@apache.org>2022-09-04 00:07:35 +0200
commit73f5bd4315bed33b6e3a24b6479305002aebeb24 (patch)
tree3aa9ace8929d9bf41afc6b32f52bce6afb782483
parent683263de0c76f133fb2dc7824775440fa6ad65fd (diff)
downloadthrift-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.pas4
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;