From 9fae0f924947838a257b2f32fa8e407b5f1e43bb Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Mon, 7 Sep 2026 22:23:12 +0200 Subject: [PATCH] httpd: do not initialise tstate through uip_conn uip_init() does not set uip_conn, and httpd_init() runs right after it, so the assignment went through a pointer nothing had assigned yet. It has stayed invisible because the startup code does clear xdata: uip_conn is NULL rather than garbage, appstate sits 28 bytes into struct uip_conn, and the byte therefore lands at xdata 0x1C. With the current map that is inside the command line buffer, at an offset nothing reads while the line is empty, and cmd_editor_init() runs later anyway. Nothing is broken today, but it is a write to an address that has nothing to do with the state being set, and it moves the moment the struct grows or the map shifts. Address the connection directly. --- httpd/httpd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpd/httpd.c b/httpd/httpd.c index bb4061b1..cbb41b93 100644 --- a/httpd/httpd.c +++ b/httpd/httpd.c @@ -101,10 +101,11 @@ inline uint8_t is_separator(uint8_t c) void httpd_init(void) __banked { config_upload = 0; // xdata is not zeroed by the startup code - __xdata struct httpd_state * __xdata s = &(uip_conn->appstate); // Start listening to port 80 uip_listen(HTONS(80)); - s->tstate = TSTATE_CLOSED; + // Not through uip_conn: it only points at a connection while uIP is + // handling one, and nothing has set it yet at init time. + uip_conns[0].appstate.tstate = TSTATE_CLOSED; fw_reset_pending = 0; // xdata is not zeroed by the startup code }