mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pulse-server: use safer spa_scnprintf
This clamps to the max size of the input buffer so that we don't write the next item past the allocated space.
This commit is contained in:
parent
2905635de3
commit
3de9d3df3b
8 changed files with 11 additions and 11 deletions
|
|
@ -162,7 +162,7 @@ static void position_to_props(struct spa_audio_info_raw *info, struct pw_propert
|
|||
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
|
||||
p = s = alloca(info->channels * 8);
|
||||
for (i = 0; i < info->channels; i++)
|
||||
p += snprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2name(info->position[i]));
|
||||
pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ static void position_to_props(struct spa_audio_info_raw *info, struct pw_propert
|
|||
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
|
||||
p = s = alloca(info->channels * 8);
|
||||
for (i = 0; i < info->channels; i++)
|
||||
p += snprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2name(info->position[i]));
|
||||
pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ struct module *create_module_null_sink(struct impl *impl, const char *argument)
|
|||
|
||||
p = s = alloca(info.channels * 8);
|
||||
for (i = 0; i < info.channels; i++)
|
||||
p += snprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2name(info.position[i]));
|
||||
pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ static void position_to_props(struct spa_audio_info_raw *info, struct pw_propert
|
|||
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
|
||||
p = s = alloca(info->channels * 8);
|
||||
for (i = 0; i < info->channels; i++)
|
||||
p += snprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2name(info->position[i]));
|
||||
pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ static void position_to_props(struct spa_audio_info_raw *info, struct pw_propert
|
|||
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
|
||||
p = s = alloca(info->channels * 8);
|
||||
for (i = 0; i < info->channels; i++)
|
||||
p += snprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2name(info->position[i]));
|
||||
pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ static void audio_info_to_props(struct spa_audio_info_raw *info, struct pw_prope
|
|||
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
|
||||
p = s = alloca(info->channels * 8);
|
||||
for (i = 0; i < info->channels; i++)
|
||||
p += snprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2name(info->position[i]));
|
||||
pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ static void audio_info_to_props(struct spa_audio_info_raw *info, struct pw_prope
|
|||
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
|
||||
p = s = alloca(info->channels * 8);
|
||||
for (i = 0; i < info->channels; i++)
|
||||
p += snprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2name(info->position[i]));
|
||||
pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,12 +209,12 @@ static void pw_properties_from_avahi_string(const char *key, const char *value,
|
|||
channel_map_parse(value, &channel_map);
|
||||
channel_map_to_positions(&channel_map, pos);
|
||||
|
||||
p = s = alloca(4 + channel_map.channels * 6);
|
||||
p += snprintf(p, 6, "[");
|
||||
p = s = alloca(4 + channel_map.channels * 8);
|
||||
p += spa_scnprintf(p, 2, "[");
|
||||
for (i = 0; i < channel_map.channels; i++)
|
||||
p += snprintf(p, 6, "%s%s", i == 0 ? "" : ",",
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ",",
|
||||
channel_id2name(pos[i]));
|
||||
p += snprintf(p, 6, "]");
|
||||
p += spa_scnprintf(p, 2, "]");
|
||||
pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s);
|
||||
}
|
||||
else if (spa_streq(key, "format")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue