From b414d2af19fac781ceb746101498b52d33c334ea Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 23 Apr 2026 16:29:16 +0200 Subject: [PATCH] pw-top: use spa_strbuf to create status bar There is nothing wrong with the use of strcat here but security tools keep complaining about it and creating bad patches for it so fix it with a strbuf. --- src/tools/pw-top.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/tools/pw-top.c b/src/tools/pw-top.c index 4c8036622..b0df55ca9 100644 --- a/src/tools/pw-top.c +++ b/src/tools/pw-top.c @@ -581,24 +581,27 @@ static void do_refresh(struct data *d, bool force_refresh) return; if (!d->batch_mode) { - char statusbar[255] = { 0 }; + char statusbar[255]; + struct spa_strbuf buf; + + spa_strbuf_init(&buf, statusbar, sizeof(statusbar)); if (!((filter->state == PW_NODE_STATE_ERROR) && (filter->followers == PW_NODE_STATE_ERROR))) { - strcpy(statusbar, "FILTER: "); + spa_strbuf_append(&buf, "FILTER: "); if (filter->state == PW_NODE_STATE_ERROR) - strcat(statusbar, "ALL"); + spa_strbuf_append(&buf, "ALL"); else for (enum pw_node_state showstate = PW_NODE_STATE_RUNNING; showstate >= PW_NODE_STATE_ERROR; showstate--) { if (showstate >= filter->state) - strcat(statusbar, state_as_string(showstate, SPA_IO_POSITION_STATE_STOPPED)); + spa_strbuf_append(&buf, "%s", state_as_string(showstate, SPA_IO_POSITION_STATE_STOPPED)); } - strcat(statusbar, "+"); + spa_strbuf_append(&buf, "+"); if (filter->followers == PW_NODE_STATE_ERROR) - strcat(statusbar, "ALL"); + spa_strbuf_append(&buf, "ALL"); else for (enum pw_node_state showstate = PW_NODE_STATE_RUNNING; showstate >= PW_NODE_STATE_ERROR; showstate--) { if (showstate >= filter->followers) - strcat(statusbar, state_as_string(showstate, SPA_IO_POSITION_STATE_STOPPED)); + spa_strbuf_append(&buf, "%s", state_as_string(showstate, SPA_IO_POSITION_STATE_STOPPED)); } }