james-sift commented on code in PR #378:
URL: https://github.com/apache/arrow-js/pull/378#discussion_r2874207463


##########
src/ipc/message.ts:
##########
@@ -29,6 +29,20 @@ import { ArrowJSON, ArrowJSONLike, ITERATOR_DONE, FileHandle 
} from '../io/inter
 /** @ignore */ const invalidMessageMetadata = (expected: number, actual: 
number) => `Expected to read ${expected} metadata bytes, but only read 
${actual}.`;
 /** @ignore */ const invalidMessageBodyLength = (expected: number, actual: 
number) => `Expected to read ${expected} bytes for message body, but only read 
${actual}.`;
 
+/**
+ * Maximum allowed metadata length (256 MB). This is a safeguard against 
corrupted
+ * files that could cause the reader to hang or consume excessive memory.
+ * @ignore
+ */
+const MAX_METADATA_LENGTH = 256 * 1024 * 1024;
+
+/**
+ * Maximum allowed message body length (2 GB). This is a safeguard against 
corrupted
+ * files that could cause the reader to hang or consume excessive memory.
+ * @ignore
+ */
+const MAX_BODY_LENGTH = 2 * 1024 * 1024 * 1024;
+

Review Comment:
   Is there a way to add a timeout here? A function that never returns and has 
no way to be interrupted isn't something we can use in production. 



-- 
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]

Reply via email to