From 1b58c8bdd0c730c911a07dbbf53e5dfb334ee2d8 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Mon, 24 Jul 2023 21:07:34 +0300 Subject: [PATCH] [mod_skinny] Fix build on Debian 12: error: array subscript 'skinny_message_t {aka struct skinny_message}[0]' is partly outside array bounds --- src/mod/endpoints/mod_skinny/skinny_protocol.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index 0ae1772521..574f2a907e 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -92,14 +92,14 @@ char* skinny_codec2string(skinny_codecs skinnycodec); /*****************************************************************************/ #define skinny_create_message(message,msgtype,field) \ - message = calloc(1, 12 + sizeof(message->data.field)); \ + message = calloc(1, sizeof(skinny_message_t)); \ message->type = msgtype; \ message->length = 4 + sizeof(message->data.field) #define skinny_create_empty_message(message,msgtype) \ - message = calloc(1, 12); \ - message->type = msgtype; \ - message->length = 4 + message = calloc(1, sizeof(skinny_empty_message_t)); \ + ((skinny_empty_message_t *)message)->type = msgtype; \ + ((skinny_empty_message_t *)message)->length = 4 /* KeepAliveMessage */ @@ -937,6 +937,12 @@ union skinny_data { #pragma pack(push, r1, 1) #endif +struct PACKED skinny_empty_message { + uint32_t length; + uint32_t version; + uint32_t type; +}; + /* * header is length+version * body is type+data @@ -954,6 +960,7 @@ struct PACKED skinny_message { #endif typedef struct skinny_message skinny_message_t; +typedef struct skinny_empty_message skinny_empty_message_t;