Skip to content

Commit 78a3890

Browse files
aurel32fabiobaltieri
authored andcommitted
net: mqtt_sn: udp: enforce maximum address size at build time
Introduce BUILD_ASSERT checks in the UDP transport implementation to ensure the configured maximum address size is large enough for the enabled IP families. Signed-off-by: Aurelien Jarno <[email protected]>
1 parent 05b9ffb commit 78a3890

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/net/lib/mqtt_sn/mqtt_sn_transport_udp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
#include <zephyr/logging/log.h>
2020
LOG_MODULE_DECLARE(net_mqtt_sn, CONFIG_MQTT_SN_LOG_LEVEL);
2121

22+
BUILD_ASSERT(CONFIG_MQTT_SN_LIB_MAX_ADDR_SIZE >= sizeof(struct net_sockaddr_in) ||
23+
!IS_ENABLED(CONFIG_NET_IPV4));
24+
25+
BUILD_ASSERT(CONFIG_MQTT_SN_LIB_MAX_ADDR_SIZE >= sizeof(struct net_sockaddr_in6) ||
26+
!IS_ENABLED(CONFIG_NET_IPV6));
27+
2228
static char *get_ip_str(const struct net_sockaddr *sa, char *s, size_t maxlen)
2329
{
2430
switch (sa->sa_family) {

0 commit comments

Comments
 (0)