CurtHagenlocher commented on code in PR #318:
URL: https://github.com/apache/arrow-dotnet/pull/318#discussion_r3135324672
##########
src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs:
##########
@@ -134,8 +135,14 @@ public override async ValueTask<RecordBatch>
ReadNextRecordBatchAsync(Cancellati
switch (message.HeaderType)
{
case MessageHeader.RecordBatch:
+ if (message.BodyLength < 0 || message.BodyLength >
int.MaxValue)
+ {
+ throw new InvalidDataException(
+ $"Cannot read batch. Message body of
{message.BodyLength} bytes is out of range");
+ }
+
var body = _flightDataStream.Current.DataBody.Memory;
- return CreateArrowObjectFromMessage(message,
CreateByteBuffer(body.Slice(0, (int)message.BodyLength)), null);
+ return CreateArrowObjectFromMessage(message,
CreateByteBuffer(body.Slice(0, checked((int)message.BodyLength))), null);
Review Comment:
Maybe there's a nanosecond performance hit!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]