Many littles fixes - time for v1
·
258 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
Fixed
- Fixed
register_requesterdirectly accessing globals_pool_stateands_pool_state_mutex—register_requester_startnow acceptspool_state_t *andSemaphoreHandle_tparameters, matching the dependency-injection pattern used by the message decoder;main.cpasses&s_pool_stateands_pool_state_mutexat startup - Fixed
send_uart_commandinmqtt_commands.cbypassingbus_send_message— now callsbus_send_bytes(extracted frombus_send_message) so MQTT commands get TX-wait, TX LED flash, and hex logging consistent with all other bus writes; removed directuart_write_bytescall anddriver/uart.hinclude frommqtt_commands.c - Fixed race condition in
dns_server_stop— replaced unreliable 100msvTaskDelay+ conditionalvTaskDeletewith a binary semaphore; the task signals the semaphore on all exit paths before callingvTaskDelete(NULL), anddns_server_stopblocks on it (3s timeout) rather than guessing when the task has finished - Fixed
/statushandler holding the pool state mutex for the entire JSON build — now takes a snapshot immediately after acquiring the mutex and releases it before any cJSON allocation, eliminating contention with the message decoder under load - Fixed potential silent truncation of MQTT broker URI — increased
broker_uristatic buffer from 192 to 256 bytes inmqtt_poolclient.c; the previous margin was tight enough that a max-length broker hostname with port would silently truncate the URI passed to the MQTT client - Fixed magic number
8used as array size forchannels_to_publishinhandle_channel_status— replaced withMAX_CHANNELSso the array size stays in sync if the constant is ever changed - Fixed
volatile boolused fors_mqtt_connectedands_mqtt_startedinmqtt_poolclient.c— replaced withatomic_bool(<stdatomic.h>) which provides correct memory-ordering guarantees on all architectures;volatileprovides no such guarantees and would be unsafe on multi-core targets - Fixed
led_flash_rx/led_flash_txblocking the tcp_bridge task for 50 ms viavTaskDelay— moved all flash work (set colour → delay → restore) into a dedicated low-priorityled_flash_task; callers now post aled_flash_type_tto a depth-4 queue and return immediately; if the queue is full under burst conditions the flash is silently dropped rather than blocking bus message processing - Fixed
tcp_bridge_stopdeletings_log_mutexwhile the task could still be insidetcp_bridge_vprintfholding it — replacedvTaskDelete(handle)with a cooperative stop:s_stop_requestedflag causes the task to exit the loop cleanly, close sockets, and give a binary semaphore before callingvTaskDelete(NULL);tcp_bridge_stopwaits on the semaphore (3s timeout with forced delete fallback) before restoring vprintf and deleting the mutex
Security
- Fixed provisioning request buffer too small for max-length SSID (32 bytes) + password (63 bytes) + JSON overhead — increased
HTTP_PROVISION_BUFFER_SIZEfrom 200 to 512 bytes - Fixed channel, light zone, and valve MQTT payloads using
snprintfwith unescapednamefields — replaced withcJSONconstruction so names containing",\, or control characters produce valid JSON - Fixed
handle_unknownheap-allocating a log buffer per unknown bus message — replaced with a stack buffer sized to3 * BUS_MESSAGE_MAX_SIZE + 1(769 bytes), eliminating heap fragmentation risk, silent OOM discard, and the signed integer overflow in3 * len - Fixed
malloc(0)and NULL pointer passed toesp_wifi_scan_get_ap_recordswhen a WiFi scan returns zero APs — now returns an empty JSON array early before themalloccall - Fixed dangling pointer in
mqtt_client_init—config.usernameandconfig.passwordwere stack-allocated fields pointed to directly by the MQTT client config; they are now copied into static buffers (s_username,s_password) before assignment, matching the existing pattern used forbroker_uri,device_id, andlwt_topic - Fixed provisioning AP password being logged in plaintext at INFO level — removed password from both
ESP_LOGIcalls inwifi_provisioning.c, preventing it from appearing on the serial console or being forwarded to any connected TCP log client - Fixed out-of-bounds read in
tcp_bridge_vprintf—vsnprintfreturns the would-be length when the buffer is too small, and that uncapped value was passed directly tosend, reading past the end of the 256-byte stack buffer; capped to buffer size before sending - Fixed XSS via unescaped dynamic content in HTML responses — added
html_escape()helper and applied it to WiFi SSID and MQTT broker in the home page, and broker/username in the MQTT config form; also converted the MQTT config form'shtml_fields[1536]fixed stack buffer to a dynamically-sized heap allocation - Fixed silent truncation of home page system info, WiFi, and MQTT rows — replaced fixed-size stack buffers (
sys_table[1024],wifi_row[96],mqtt_row[256]) with heap-allocated buffers sized viasnprintf(NULL, 0, ...), matching the pattern used byget_page_header/get_page_nav; also explicitly null-terminatesap_info.ssidbefore use - Fixed OTA handler accepting zero, negative, or oversized
Content-Lengthvalues — added validation that rejects requests outside the range 1–OTA_MAX_FIRMWARE_SIZE(0x1E0000, matching the partition table) before entering the receive loop - Fixed race condition in
handle_mode_control_cmd,handle_favourite_label, andhandle_favourite_enable—mqtt_publish_favouritewas called with a raw pointer to shared pool state after the mutex was released; all three now capture a snapshot inside the mutex and pass&state_snapshot, consistent with every other publish call in the decoder - Fixed out-of-bounds array writes in light zone register handlers (
handle_light_zone_state,_color,_active,_multicolor,_name) — zone index derived from busreg_idwas not bounds-checked before indexinglighting[MAX_LIGHT_ZONES], allowing a crafted or malformed bus packet to corrupt adjacent fields inpool_state_t; dispatch tablereg_endvalues tightened tobase + MAX_LIGHT_ZONES - 1and an explicit bounds check added in each handler
Full Changelog: v0.10.0...v1.0.0