From ed527afbaf2a7ce0be42967666883a3423bbe8ad Mon Sep 17 00:00:00 2001 From: ruv Date: Thu, 11 Jun 2026 10:48:15 -0400 Subject: [PATCH] =?UTF-8?q?test(fuzz):=20esp=5Fnetif/ping=5Fsock/ip=5Faddr?= =?UTF-8?q?=20stubs=20=E2=80=94=20un-break=20ADR-061=20fuzz=20build=20afte?= =?UTF-8?q?r=20#954?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit csi_collector.c gained esp_netif.h / ping/ping_sock.h / lwip/ip_addr.h includes for the #954 gateway self-ping; the host-fuzz stub env lacked them, breaking the fuzz build on main since 5789351b7. Stubs return no-gateway so the self-ping path early-outs (compiles + links, never exercised — matches the fuzz threat model which targets frame serialization, not the network stack). Co-Authored-By: claude-flow --- .../esp32-csi-node/test/stubs/esp_netif.h | 48 +++++++++++ .../esp32-csi-node/test/stubs/lwip/ip_addr.h | 20 +++++ .../test/stubs/ping/ping_sock.h | 79 +++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 firmware/esp32-csi-node/test/stubs/esp_netif.h create mode 100644 firmware/esp32-csi-node/test/stubs/lwip/ip_addr.h create mode 100644 firmware/esp32-csi-node/test/stubs/ping/ping_sock.h diff --git a/firmware/esp32-csi-node/test/stubs/esp_netif.h b/firmware/esp32-csi-node/test/stubs/esp_netif.h new file mode 100644 index 00000000..89ff9f60 --- /dev/null +++ b/firmware/esp32-csi-node/test/stubs/esp_netif.h @@ -0,0 +1,48 @@ +/* Host-fuzzing stub for esp_netif.h (ADR-061). + * + * csi_collector.c's #954 self-ping needs the STA netif handle + gateway IP. + * In the fuzz environment there is no network stack: the handle lookup + * returns NULL, so csi_start_self_ping() takes its no-gateway early-out and + * the esp_ping path is never exercised (but must compile and link). + */ +#pragma once + +#include +#include + +#include "esp_err.h" + +typedef struct esp_netif_obj esp_netif_t; + +typedef struct { + uint32_t addr; +} esp_ip4_addr_t; + +typedef struct { + esp_ip4_addr_t ip; + esp_ip4_addr_t netmask; + esp_ip4_addr_t gw; +} esp_netif_ip_info_t; + +static inline esp_netif_t *esp_netif_get_handle_from_ifkey(const char *if_key) +{ + (void)if_key; + return NULL; /* no netif in fuzz env -> self-ping early-out */ +} + +static inline esp_err_t esp_netif_get_ip_info(esp_netif_t *netif, esp_netif_ip_info_t *ip_info) +{ + (void)netif; + (void)ip_info; + return ESP_FAIL; +} + +static inline char *esp_ip4addr_ntoa(const esp_ip4_addr_t *addr, char *buf, int buflen) +{ + if (buf != NULL && buflen > 0) { + snprintf(buf, (size_t)buflen, "%u.%u.%u.%u", + (unsigned)(addr->addr & 0xff), (unsigned)((addr->addr >> 8) & 0xff), + (unsigned)((addr->addr >> 16) & 0xff), (unsigned)((addr->addr >> 24) & 0xff)); + } + return buf; +} diff --git a/firmware/esp32-csi-node/test/stubs/lwip/ip_addr.h b/firmware/esp32-csi-node/test/stubs/lwip/ip_addr.h new file mode 100644 index 00000000..0b979be2 --- /dev/null +++ b/firmware/esp32-csi-node/test/stubs/lwip/ip_addr.h @@ -0,0 +1,20 @@ +/* Host-fuzzing stub for lwip/ip_addr.h (ADR-061). Minimal surface for the + * #954 self-ping block; never functionally exercised in the fuzz env. */ +#pragma once + +#include + +typedef struct { + uint32_t addr; + uint8_t type; +} ip_addr_t; + +static inline int ipaddr_aton(const char *cp, ip_addr_t *addr) +{ + (void)cp; + if (addr != NULL) { + addr->addr = 0; + addr->type = 0; + } + return 1; +} diff --git a/firmware/esp32-csi-node/test/stubs/ping/ping_sock.h b/firmware/esp32-csi-node/test/stubs/ping/ping_sock.h new file mode 100644 index 00000000..89e993f2 --- /dev/null +++ b/firmware/esp32-csi-node/test/stubs/ping/ping_sock.h @@ -0,0 +1,79 @@ +/* Host-fuzzing stub for ping/ping_sock.h (ADR-061). The #954 self-ping is + * unreachable in the fuzz env (esp_netif stub returns no gateway), but the + * symbols must compile and link. */ +#pragma once + +#include + +#include "esp_err.h" +#include "lwip/ip_addr.h" + +typedef void *esp_ping_handle_t; + +typedef void (*esp_ping_cb_t)(esp_ping_handle_t hdl, void *args); + +typedef struct { + uint32_t count; + uint32_t interval_ms; + uint32_t timeout_ms; + uint32_t data_size; + uint8_t tos; + int ttl; + ip_addr_t target_addr; + uint32_t task_stack_size; + uint32_t task_prio; + uint32_t interface; +} esp_ping_config_t; + +#define ESP_PING_COUNT_INFINITE (0) + +#define ESP_PING_DEFAULT_CONFIG() \ + { \ + .count = 5, \ + .interval_ms = 1000, \ + .timeout_ms = 1000, \ + .data_size = 64, \ + .tos = 0, \ + .ttl = 64, \ + .target_addr = {0, 0}, \ + .task_stack_size = 2048, \ + .task_prio = 2, \ + .interface = 0, \ + } + +typedef struct { + void *cb_args; + esp_ping_cb_t on_ping_success; + esp_ping_cb_t on_ping_timeout; + esp_ping_cb_t on_ping_end; +} esp_ping_callbacks_t; + +static inline esp_err_t esp_ping_new_session(const esp_ping_config_t *config, + const esp_ping_callbacks_t *cbs, + esp_ping_handle_t *hdl_out) +{ + (void)config; + (void)cbs; + if (hdl_out != NULL) { + *hdl_out = (void *)0; + } + return ESP_FAIL; /* never starts a ping task in the fuzz env */ +} + +static inline esp_err_t esp_ping_start(esp_ping_handle_t hdl) +{ + (void)hdl; + return ESP_OK; +} + +static inline esp_err_t esp_ping_stop(esp_ping_handle_t hdl) +{ + (void)hdl; + return ESP_OK; +} + +static inline esp_err_t esp_ping_delete_session(esp_ping_handle_t hdl) +{ + (void)hdl; + return ESP_OK; +}