From 01a827b2a0186dce0b324391f38e74acdb7af296 Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Tue, 21 May 2024 09:05:15 +0000 Subject: [PATCH] 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 (cherry picked from commit 62aba6df38df7203b2565f77afc2fb09e4bc43d6) --- src/include/denc.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/include/denc.h b/src/include/denc.h index d075dd5183185..623e4639cb57f 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()); \ } \ -- 2.39.5