mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-28 06:46:42 -04:00
tools: replace strcpy/strcat with snprintf
Potential buffer overflow when concatenating strings to fixed-size 255-byte statusbar buffer. Fixes buffer overflow issue.
This commit is contained in:
parent
e490c503fd
commit
b445e82bcb
1 changed files with 7 additions and 6 deletions
|
|
@ -582,23 +582,24 @@ static void do_refresh(struct data *d, bool force_refresh)
|
|||
|
||||
if (!d->batch_mode) {
|
||||
char statusbar[255] = { 0 };
|
||||
int len = 0;
|
||||
|
||||
if (!((filter->state == PW_NODE_STATE_ERROR) &&
|
||||
(filter->followers == PW_NODE_STATE_ERROR))) {
|
||||
|
||||
strcpy(statusbar, "FILTER: ");
|
||||
len = snprintf(statusbar, sizeof(statusbar), "FILTER: ");
|
||||
if (filter->state == PW_NODE_STATE_ERROR)
|
||||
strcat(statusbar, "ALL");
|
||||
len += snprintf(statusbar + len, sizeof(statusbar) - len, "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));
|
||||
len += snprintf(statusbar + len, sizeof(statusbar) - len, "%s", state_as_string(showstate, SPA_IO_POSITION_STATE_STOPPED));
|
||||
}
|
||||
strcat(statusbar, "+");
|
||||
len += snprintf(statusbar + len, sizeof(statusbar) - len, "+");
|
||||
if (filter->followers == PW_NODE_STATE_ERROR)
|
||||
strcat(statusbar, "ALL");
|
||||
len += snprintf(statusbar + len, sizeof(statusbar) - len, "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));
|
||||
len += snprintf(statusbar + len, sizeof(statusbar) - len, "%s", state_as_string(showstate, SPA_IO_POSITION_STATE_STOPPED));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue