mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
conf.c: snd_config_set_id: prevent duplicate ids
snd_config_add() checks for duplicate ids, but it was possible to create duplicates by adding a note and changing the id afterwards with snd_config_set_id(); so we have to add a check there, too. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
This commit is contained in:
parent
2c4b3c7d09
commit
e2317969e1
1 changed files with 8 additions and 0 deletions
|
|
@ -1521,9 +1521,17 @@ int snd_config_get_id(const snd_config_t *config, const char **id)
|
|||
*/
|
||||
int snd_config_set_id(snd_config_t *config, const char *id)
|
||||
{
|
||||
snd_config_iterator_t i, next;
|
||||
char *new_id;
|
||||
assert(config);
|
||||
if (id) {
|
||||
if (config->father) {
|
||||
snd_config_for_each(i, next, config->father) {
|
||||
snd_config_t *n = snd_config_iterator_entry(i);
|
||||
if (n != config && strcmp(id, n->id) == 0)
|
||||
return -EEXIST;
|
||||
}
|
||||
}
|
||||
new_id = strdup(id);
|
||||
if (!new_id)
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue