Skip to content

Commit 757b576

Browse files
jhirsihenrikbrixandersen
authored andcommitted
net: ppp: always set FSM name in ppp_fsm_name_set
Previously the name was only set when CONFIG_NET_L2_PPP_LOG_LEVEL >= LOG_LEVEL_DBG. NET_ERR/NET_WRN in ipv6cp (and others) use fsm->name as %s at any log level, which could pass NULL into the logger and crash in cbprintf/strlen. Always assign the name so logging is safe. Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
1 parent da0c815 commit 757b576

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

‎subsys/net/l2/ppp/misc.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,8 @@ const char *ppp_option2str(enum ppp_protocol_type protocol,
366366

367367
void ppp_fsm_name_set(struct ppp_fsm *fsm, const char *name)
368368
{
369-
#if CONFIG_NET_L2_PPP_LOG_LEVEL >= LOG_LEVEL_DBG
370-
fsm->name = name;
371-
#else
372-
ARG_UNUSED(fsm);
373-
ARG_UNUSED(name);
374-
#endif
369+
/* Always set name: NET_ERR/NET_WRN in ipv6cp/ipcp/lcp use fsm->name
370+
* regardless of CONFIG_NET_L2_PPP_LOG_LEVEL.
371+
*/
372+
fsm->name = (name != NULL) ? name : "";
375373
}

0 commit comments

Comments
 (0)