From: Adam Kupczyk Date: Tue, 21 May 2024 09:05:15 +0000 (+0000) Subject: include/denc: Add missing check for compat X-Git-Tag: testing/wip-vshankar-testing-20240718.183435-debug~13^2~6 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=62aba6df38df7203b2565f77afc2fb09e4bc43d6;p=ceph-ci.git include/denc: Add missing check for compat Now decoder throws if compat signalled in message is higher than version of decoder. Signed-off-by: Adam Kupczyk --- diff --git a/src/include/denc.h b/src/include/denc.h index d075dd51831..623e4639cb5 100644 --- a/src/include/denc.h +++ b/src/include/denc.h @@ -1818,8 +1818,13 @@ inline std::enable_if_t decode_nohead( __u8 *struct_compat, \ char **start_pos, \ uint32_t *struct_len) { \ + __u8 code_v = *struct_v; \ denc(*struct_v, p); \ denc(*struct_compat, p); \ + if (code_v < *struct_compat) \ + throw ::ceph::buffer::malformed_input(fmt::format( \ + "Decoder at '{}' v={} cannot decode v={} minimal_decoder={}", \ + __PRETTY_FUNCTION__, code_v, *struct_v, *struct_compat)); \ denc(*struct_len, p); \ *start_pos = const_cast(p.get_pos()); \ } \