From 926365b64ead9d123576f12ae095e5b3a6aca048 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Mon, 18 Oct 2021 12:12:54 +0200 Subject: [PATCH] fix(legacy): Fix compile-time check of maximum protobuf message size. --- legacy/firmware/.changelog.d/1854.fixed | 1 + legacy/firmware/messages.h | 2 +- legacy/firmware/protob/messages_map.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 legacy/firmware/.changelog.d/1854.fixed diff --git a/legacy/firmware/.changelog.d/1854.fixed b/legacy/firmware/.changelog.d/1854.fixed new file mode 100644 index 0000000000..de09538267 --- /dev/null +++ b/legacy/firmware/.changelog.d/1854.fixed @@ -0,0 +1 @@ +Fix incorrect compile-time check of maximum protobuf message size. diff --git a/legacy/firmware/messages.h b/legacy/firmware/messages.h index fa8fc1d30e..ad362922c0 100644 --- a/legacy/firmware/messages.h +++ b/legacy/firmware/messages.h @@ -29,7 +29,7 @@ #define MSG_HEADER_SIZE 9 // Maximum size of an incoming protobuf-encoded message without headers. -#define MSG_IN_ENCODED_SIZE (15 * 1024) +#define MSG_IN_ENCODED_SIZE (16 * 1024) // Maximum size of a C struct containing a decoded incoming message. #define MSG_IN_DECODED_SIZE (15 * 1024) diff --git a/legacy/firmware/protob/messages_map.py b/legacy/firmware/protob/messages_map.py index f6f9a3a2b8..f901d3492b 100755 --- a/legacy/firmware/protob/messages_map.py +++ b/legacy/firmware/protob/messages_map.py @@ -97,7 +97,7 @@ def handle_message(fh, fl, skipped, message): if encoded_size: fl.write( - f'_Static_assert({encoded_size} >= sizeof({short_name}_size), "msg buffer too small");\n' + f'_Static_assert({encoded_size} >= {short_name}_size, "msg buffer too small");\n' ) if decoded_size: