|
80 | 80 | peer_cert_validity]). |
81 | 81 | -define(UNKNOWN_FIELD, unknown_field). |
82 | 82 | -define(SILENT_CLOSE_DELAY, 3_000). |
83 | | --define(MAX_REFERENCE_SIZE, 255). |
| 83 | +-define(IS_INVALID_REF(Ref), is_binary(Ref) andalso byte_size(Ref) > 255). |
84 | 84 |
|
85 | 85 | -import(rabbit_stream_utils, [check_write_permitted/2, |
86 | 86 | check_read_permitted/3]). |
@@ -1665,7 +1665,7 @@ handle_frame_post_auth(Transport, |
1665 | 1665 | State, |
1666 | 1666 | {request, CorrelationId, |
1667 | 1667 | {declare_publisher, _PublisherId, WriterRef, S}}) |
1668 | | - when is_binary(WriterRef), byte_size(WriterRef) > ?MAX_REFERENCE_SIZE -> |
| 1668 | + when ?IS_INVALID_REF(WriterRef) -> |
1669 | 1669 | {Code, Counter} = case check_write_permitted(stream_r(S, C), User) of |
1670 | 1670 | ok -> |
1671 | 1671 | {?RESPONSE_CODE_PRECONDITION_FAILED, ?PRECONDITION_FAILED}; |
@@ -1922,7 +1922,7 @@ handle_frame_post_auth(Transport, #stream_connection{} = Connection, State, |
1922 | 1922 | handle_frame_post_auth(Transport, {ok, #stream_connection{user = User} = C}, State, |
1923 | 1923 | {request, CorrelationId, |
1924 | 1924 | {subscribe, _, S, _, _, #{ <<"name">> := N}}}) |
1925 | | - when is_binary(N), byte_size(N) > ?MAX_REFERENCE_SIZE -> |
| 1925 | + when ?IS_INVALID_REF(N) -> |
1926 | 1926 | {Code, Counter} = case check_read_permitted(stream_r(S, C), User,#{}) of |
1927 | 1927 | ok -> |
1928 | 1928 | {?RESPONSE_CODE_PRECONDITION_FAILED, ?PRECONDITION_FAILED}; |
@@ -3463,7 +3463,7 @@ clean_state_after_stream_deletion_or_failure(MemberPid, Stream, |
3463 | 3463 | {not_cleaned, C2#stream_connection{stream_leaders = Leaders1}, S2} |
3464 | 3464 | end. |
3465 | 3465 |
|
3466 | | -store_offset(Reference, _, _, C) when is_binary(Reference), byte_size(Reference) > ?MAX_REFERENCE_SIZE -> |
| 3466 | +store_offset(Reference, _, _, C) when ?IS_INVALID_REF(Reference) -> |
3467 | 3467 | rabbit_log:warning("Reference is too long to store offset: ~p", [byte_size(Reference)]), |
3468 | 3468 | C; |
3469 | 3469 | store_offset(Reference, Stream, Offset, Connection0) -> |
|
0 commit comments