mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-09 08:21:08 -04:00
tools: avoid strcat in pw-cat
We might overflow the path buffer when we strcat the provided filename into it, which might crash or cause unexpected behaviour. Instead use spa_scnprintf which avoids overflow and properly truncates and null-terminates the string. Found by Claude Code.
This commit is contained in:
parent
337801717e
commit
d7be4353ad
1 changed files with 2 additions and 3 deletions
|
|
@ -1860,15 +1860,14 @@ static int setup_encodedfile(struct data *data)
|
||||||
int num_channels;
|
int num_channels;
|
||||||
unsigned int stream_index;
|
unsigned int stream_index;
|
||||||
const AVCodecParameters *codecpar;
|
const AVCodecParameters *codecpar;
|
||||||
char path[256] = { 0 };
|
char path[PATH_MAX];
|
||||||
|
|
||||||
/* We do not support record with encoded media */
|
/* We do not support record with encoded media */
|
||||||
if (data->mode == mode_record) {
|
if (data->mode == mode_record) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(path, "file:");
|
spa_scnprintf(path, sizeof(path), "file:%s", data->filename);
|
||||||
strcat(path, data->filename);
|
|
||||||
|
|
||||||
data->encoded.format_context = NULL;
|
data->encoded.format_context = NULL;
|
||||||
if ((ret = avformat_open_input(&data->encoded.format_context, path, NULL, NULL)) < 0) {
|
if ((ret = avformat_open_input(&data->encoded.format_context, path, NULL, NULL)) < 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue