shivendra-dev54 commented on code in PR #3455:
URL: https://github.com/apache/fory/pull/3455#discussion_r2894729985
##########
cpp/fory/serialization/collection_serializer.h:
##########
@@ -611,15 +618,28 @@ struct Serializer<
if (FORY_PREDICT_FALSE(ctx.has_error())) {
return std::vector<T, Alloc>();
}
+ // 1. Guardrail: Enforce max_binary_size for binary byte-length reads
+ if (FORY_PREDICT_FALSE(total_bytes_u32 > ctx.config().max_binary_size)) {
+ ctx.set_error(Error::invalid_data("Binary size exceeds
max_binary_size"));
+ return std::vector<T, Alloc>();
+ }
if (sizeof(T) == 0) {
return std::vector<T, Alloc>();
}
+
+ // 2. Convert bytes to element count and check max_collection_size
+ size_t elem_count = total_bytes_u32 / sizeof(T);
+ if (FORY_PREDICT_FALSE(elem_count > ctx.config().max_collection_size)) {
Review Comment:
I have updated the arithmetic vector path to use `max_binary_size` instead
of `max_collection_size`, as suggested. I've also updated the unit tests to
verify this behavior.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]