mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
handle snprintf errors better
This commit is contained in:
parent
99b1ce96ed
commit
8184d4576a
2 changed files with 18 additions and 7 deletions
|
|
@ -455,12 +455,15 @@ int format_info_from_spec(struct format_info *info, struct sample_spec *ss,
|
|||
pw_properties_setf(info->props, "format.channels", "%d", ss->channels);
|
||||
if (map && map->channels == ss->channels) {
|
||||
char chmap[1024] = "";
|
||||
int i, o;
|
||||
int i, o, r;
|
||||
uint32_t aux = 0;
|
||||
|
||||
for (i = 0, o = 0; i < map->channels; i++) {
|
||||
o += snprintf(chmap+o, sizeof(chmap)-o, "%s%s", i == 0 ? "" : ",",
|
||||
r = snprintf(chmap+o, sizeof(chmap)-o, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2paname(map->map[i], &aux));
|
||||
if (r < 0 || o + r >= (int)sizeof(chmap))
|
||||
return -ENOSPC;
|
||||
o += r;
|
||||
}
|
||||
pw_properties_setf(info->props, "format.channel_map", "\"%s\"", chmap);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue