fix: mqttsn session fixes, better logging - #19
Conversation
| /** | ||
| * @brief Function to disconnect from the MQTT-SN gateway. | ||
| */ | ||
| int mqttsn_disconnect() { |
There was a problem hiding this comment.
I was reading through this and I actually think there's a risk socket exhaustion here since you never clean up the tp socket in this method.
| @@ -71,23 +71,33 @@ int mqttsn_initialize() { | |||
| client_initialized = true; | |||
|
|
|||
| char *ip_str = getIpAddressFromHostname(CONFIG_FINDMYCAT_CLOUD_HOSTNAME); | |||
There was a problem hiding this comment.
There's no null check on this, what happens if this fails to resolve and gets a NULL value and you pass null into zsock_inet_pton()?
From what I can see it goes into Zephyr's zsock_inet_pton() method which calls z_impl_net_addr_pton this then tries to dereference *src which would be null causing a fatal crash?
There was a problem hiding this comment.
Thinking about this actually, this could cause a full on crash with no recovery?
| LOG_HEXDUMP_DBG(&gateway, sizeof(gateway), "gateway"); | ||
|
|
||
| LOG_INF("Connecting to MQTT-SN server"); | ||
| LOG_INF("Connecting to MQTT-SN gateway %s:%d as client %s, topic %s", ip_str, |
There was a problem hiding this comment.
Looks like this is the last use of ip_str and getIpAddressFromHostname does a memory allocation. You'll want to free up that allocation otherwise it would get lost in memory and I think this would accumulate over time as MQTT-SN is used causing a memory leak due to lost allocations.
No description provided.