syslog: do not read the connection before there is one

udp_callbacks() offers every UDP connection event to syslog_callback(),
which decides whether the event is its own by comparing the local port
against state.syslog_conn->lport. The pointer is null until syslog is
started: syslog_init() clears it at boot and syslog_stop() clears it
again, so with syslog off, which is the default, every poll dereferences
null and reads whatever lives at the bottom of xdata.

Should that word ever match the port being offered, the send path runs on
another application's connection, overwrites uip_appdata and drops the
log line it was holding.

Test the pointer first.
This commit is contained in:
bloqaudio committed 2026-09-18 13:59:59 -05:00
1 parent 0cc09e4015
commit 9e3863cc4e
1 file changed
+1 -1
+1 -1
View File
@@ -60,7 +60,7 @@ void syslog_stop(void) __banked
void syslog_callback(uint16_t lport) __banked void syslog_callback(uint16_t lport) __banked
{ {
uint16_t syslog_hdr; uint16_t syslog_hdr;
if (lport != state.syslog_conn->lport) if (!state.syslog_conn || lport != state.syslog_conn->lport)
return; return;
if ((state.readptr != state.writeptr) && state.line_available) if ((state.readptr != state.writeptr) && state.line_available)