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:
Wim Taymans 2021-12-22 21:34:29 +01:00
parent 2905635de3
commit 3de9d3df3b
8 changed files with 11 additions and 11 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}