117 Commits

Author SHA1 Message Date
Euripedes Rocha Filho 08615177e3 refactor: Moves outbox to an internal library to improve testing 2026-05-27 07:03:33 +02:00
Bogdan Kolendovskyy 32df7e27fc feat: Add support for percent-encoding in password and it's corresponding test
Add support of percent-encoded characters when passing the username and password in URI

Closes https://github.com/espressif/esp-mqtt/issues/294
2026-04-23 16:05:24 +02:00
Eun0us ffd44fb424 fix: fix signed integer overflow in remaining length decoding
The expression (buffer[i] & 0x7f) << (7 * (i - 1)) performs a left
shift on a signed int. When i >= 5, the shift amount reaches 28+ and
0x7f << 28 overflows INT_MAX, which is undefined behavior.

Per MQTT 3.1.1 section 2.2.3, the Remaining Length field uses at most
4 continuation bytes, so limit the decoding loop accordingly. Also
cast to size_t in mqtt_get_total_length() where totlen is already
size_t.

Affects mqtt_get_total_length() and mqtt_get_publish_data().

Found via coverage-guided fuzzing (libFuzzer + UBSan).
2026-04-07 11:02:39 +02:00
Euripedes Rocha a5695b05f3 Merge branch 'fix/mqtt5_var_len_ub' into 'master'
fix(mqtt5): Fix UB in variable len processing

See merge request espressif/esp-mqtt!270
2026-02-24 13:32:42 +01:00
David Cermak e427ebb7ea fix(mqtt5): Sanitize propery len/types to harden mqtt5-msg 2026-02-03 12:34:43 +01:00
David Cermak 3c5777d706 fix(mqtt5): Fix UB in variable len processing 2026-01-06 12:59:46 +01:00
Euripedes Rocha Filho 04f8e3765d chore: Adds pre-commit checks and introduce conventional commits 2025-09-26 17:45:16 +02:00
Alexey Lapshin 07399ed72d fix: actualize newlib Kconfig options 2025-08-21 15:32:11 +08:00
Euripedes Rocha Filho f85e8a925d feat: Add logging to outbox message deletion. 2025-08-20 20:18:37 +08:00
dhb 00cc9dbd9a feat(mqtt): enable custom TLS cipher suites for MQTTs
- Add `ciphersuites_list` to `esp_mqtt_client_config_t` for specifying TLS cipher suites.
- Update SSL transport configuration to use the provided cipher suites.
- Users are responsible for managing the cipher suites list memory.
2025-05-21 10:05:00 +02:00
hrushikesh.bhosale b35a69121c feat(mqtt): Add support for ECDSA signing
Added support for ECDSA signing in MQTT.
2025-05-14 12:14:43 +05:30
Euripedes Rocha c395c2f0f3 fix: Change error message to fix warning.
This fixes an error on gen_esp_err_to_name.py. The message wasn't adding
information to the user so removal of ESP_OK text is the simpler fix.
2025-04-08 14:36:09 +02:00
Flavia Caforio 470cb93049 mqtt_client: Manage disconnect packet
In the mqtt5 protocol the broker can disconnect the client with
a disconnect packet. This packet contains a reason value that can be
useful for certain applications in which it is important to know
the reason of disconnection.
While the client is connected is possible that a disconnect packet
is reaceived by the broker to force a disconnection. Before this
patch this approach causes a generic error on transport in case of
disconnection from the broker. If the packet is managed before getting
an error it is possible to save the reason code in the
disconnect_return_code variable in the error_handle, and dispatch
the disconnect event that can be managed by the application event
loop, that now can know the reason of disconnection from the broker.
Reset the variable in case of error.

Signed-off-by: Flavia Caforio <flavia.caforio@amarulasolutions.com>
2025-02-18 16:24:13 +01:00
Bogdan Kolendovskyy 7c3227a24d feat: Add TCP keepalive configuration 2024-08-22 11:18:43 +02:00
Euripedes Rocha 0071aca61d Fix: Allow to publish using only topic alias on MQTT5
Previously if message had a NULL topic filter the client would reject
and not build the messages. This fix it allowing the usage of topic
alias.
2024-05-23 13:56:34 +08:00
Ss Wang 37478a9c00 add return to faile_message, avoid segment fault
should not use response_topic when calloc failed
2024-04-02 10:48:45 +02:00
Euripedes Rocha 726e5f2fce fix: Minor warning of unused variable
In case of hardcoded id mac array was unused.
2024-03-28 14:16:34 +01:00
Euripedes Rocha 5e3abd4b8c fix: Cover the case for SOC without MAC address
We need to cover for the case where the available MAC isn't defined in
soc caps. E.g. A new target is being introduced but the support isn't
complete yet.
2024-03-28 12:40:07 +01:00
Rocha Euripedes 37cb056c5f Merge branch 'feature/atomic_state' into 'master'
Make state and size atomic

See merge request espressif/esp-mqtt!199
2024-03-22 15:26:15 +08:00
Euripedes Rocha 657a2aea77 fix: Make automatic client_id soc dependent
When creating the client_id for user, the library uses the device MAC.
For some of our devices WIFI isn't available and the library needs to select
a different MAC to use.
2024-03-14 07:31:37 +01:00
Euripedes Rocha 891380bdf5 feat: Make state and size atomic
This makes the mqtt client state atomic to reduce the scope of locking in
some parts of the code.
2024-03-12 08:49:36 +01:00
Euripedes Rocha ea0df31e00 fix: Move buffer initialization to set config
When calling set config message buffers were not affected because the
creation was handled on init.

Closes https://github.com/espressif/esp-mqtt/issues/267
2023-10-25 07:47:05 +00:00
Euripedes Rocha 00ee059bf8 fix: Uses caps allocation for data buffer instead of item struct
Once introduced the memory destination for outbox was incorrectly
allocating the outbox data structuture instead of data buffer to the
selected memory.
2023-09-13 08:04:38 +02:00
Euripedes Rocha a3b04f2d0a fix: LOG format strings
Fix log format strings and remove no-format warning configuration.
2023-06-30 10:17:32 +02:00
Euripedes Rocha 6c849c62ef Fix: Allocation for connection buffer was incorrectly done.
By mistake calloc parameters were incorrect.
2023-06-21 08:24:46 +02:00
Rocha Euripedes aee82c7ba8 Merge branch 'bugfix/outbox_init_failure' into 'master'
Fix: Outbox was leaked in case of initialization failure

See merge request espressif/esp-mqtt!180
2023-06-14 21:46:04 +08:00
Euripedes Rocha 363fbf7dab feat: Add option to bind interface of use
Enable user to set which interface should be used for client network,
allowing client to be binded to the interface selected by user forcing
it to go through the selected interface.

Closes https://github.com/espressif/esp-mqtt/issues/253
2023-06-14 14:48:44 +02:00
Euripedes Rocha 5d491a45ce Fix: Outbox was leaked in case of initialization failure
If the the list allocation fail, outbox must be freed.
2023-06-14 13:36:42 +02:00
Euripedes Rocha 372ab7b374 feat: Introduces outbox limit
A memory limit for the outbox can be configured.
User will not be able to publish or enqueue if the new message goes
beyond the configured limit.
2023-06-13 15:59:55 +02:00
Euripedes Rocha 21a5491d53 Removes unused outbox functions. 2023-06-13 11:56:11 +02:00
Euripedes Rocha 122875bf8a refactor: Group access to output buffer in mqtt_connection_t
- Moves mqtt_connect_info to mqtt_connection_t.
  - Removes outbound_message in favor of accessing it trough connection.
2023-06-13 11:56:05 +02:00
Rocha Euripedes ed628098a1 Merge branch 'feature/custom_transport' into 'master'
Add custom transport configuration

See merge request espressif/esp-mqtt!169
2023-06-13 14:30:24 +08:00
Euripedes Rocha a492935951 Removes leftover calls to event_handler
The possibility to add a callback as custom handler was removed from
the client in favor of esp_event. These removes the older alternative
that wasn't possible to use.
2023-06-09 10:44:50 +02:00
Niklas Gürtler 6195762d28 Added support to set server common name. 2023-06-08 08:46:41 +02:00
Euripedes Rocha a5c1b441dc feat: Add custom transport configuration
Today there is no way to add a new transport without applying
modifications to the transport list. This impose limitations on the
client usage. Adding the custom configuration we enable user defined
transports.
2023-06-08 06:38:53 +00:00
Euripedes Rocha da6d38a17e Removes pending message count
The information was used only to log remaining messages on debug log.
It was checked on writing but updated prior to every call making the
verification meaningless.
2023-04-21 08:40:12 +02:00
Euripedes Rocha 2c71f9e69b feat: Adds a configuration for outbox data destination
Allow user to move outbox data to external SPI RAM.
2023-04-12 08:43:40 +00:00
Euripedes Rocha 32102558d3 Feature: Enable SUBSCRIBE to multiple topics
- Adds an api for multiple topics on SUBSCRIBE message.

Apply 2 suggestion(s) to 1 file(s)

Removing headers

y
2023-02-03 14:19:24 +01:00
Rocha Euripedes 2fa945d0b8 Adds Kconfig option to configure poll read timeout
A new Kconfig option was added to allow users to configure poll read
timeout.

Closes: https://github.com/espressif/esp-mqtt/issues/245
2023-02-02 20:52:02 +08:00
yuanjianmin ed76036744 mqtt5: Fix flow control will regard the DUP packet and not consider PUBCOMP packet
Closes https://github.com/espressif/esp-mqtt/issues/243
2023-01-18 14:16:28 +08:00
Euripedes Rocha f80772b8d7 Bugfix: Remove Remove possible null pointer dereferences
- Removed a possible derefrence on data in case of MQTT5 SUBACK with
  MQTT5 disabled.
- Covered a case of NULL data on message with negative size.
- Use correct type on calloc for alpn_protos
- Changed strcasecmp to strncasecmp.
2022-12-15 13:02:46 +01:00
Rocha Euripedes fb42588a03 Fix the default configuration for event queue
- Event queue should be disabled, making it an opt-in feature.
2022-11-23 20:40:31 +08:00
David Cermak 97503cceb3 client: Add support for user events
Also supporting configurable queue size for the internal event loop.

Closes https://github.com/espressif/esp-mqtt/issues/230
2022-07-29 09:08:52 +02:00
Euripedes Rocha ae53d799da Restructure the client configuration struct
- Groups configuration fields by context.
- Removes user_context in favor of the event loop.
2022-07-13 08:37:20 -03:00
Euripedes Rocha 89e5c6014f fix: MQTT tick not starting on connect and switch to esp_timer
- Tick should be updated on connect
- Dependency of system timer removed to avoid issues when updating via
  SNTP

Closes https://github.com/espressif/esp-mqtt/issues/225
2022-06-23 12:43:58 -03:00
yuanjm fdf2aeb36f Seperate MQTT5 from MQTT 3.1.1 2022-06-14 09:37:46 +00:00
yuanjm 3d275f42b9 mqtt: Support MQTT5 protocol 2022-06-14 09:37:46 +00:00
Euripedes Rocha f6caaff254 Fix WSS default port selection through menuconfig.
Evaluate the correct define to select default port.

 - Closes https://github.com/espressif/esp-mqtt/issues/223
2022-05-17 07:16:07 +00:00
Euripedes Rocha 2c2e6f38b5 Changes the moment we update keepalive_tick.
In order to keep sending keep alive messages in the scenario were client
publish too often with QoS0 the keepalive is updated when the response
is received.
2022-04-07 09:14:03 -03:00
AndriiFilippov fb3184cc14 Make the mqtt submodule logging tags lower case 2022-04-04 10:33:06 +02:00