diff options
author | Jaroslav Kysela <perex@perex.cz> | 2006-09-28 15:47:25 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2006-09-28 15:47:25 +0200 |
commit | 1dc96732c2431806dc29aad4961e07ca92f53e86 (patch) | |
tree | 438cc30cbe922a1627fac58a6c87b2e5e585e9fa /src/conf.c | |
parent | 436b003173430a45a5fe66376fa27ab92728507b (diff) | |
download | alsa-lib-1dc96732c2431806dc29aad4961e07ca92f53e86.tar.gz |
configuration: avoid endless loop when a key refers to itself
remove one warning from tlv_read routine in control.c
Diffstat (limited to 'src/conf.c')
-rw-r--r-- | src/conf.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -2404,9 +2404,16 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) #define SND_CONFIG_SEARCH_ALIAS(config, base, key, result, fcn1, fcn2) \ { \ snd_config_t *res = NULL; \ + char *old_key; \ int err, first = 1; \ assert(config && key); \ - do { \ + while (1) { \ + old_key = strdup(key); \ + if (old_key == NULL) { \ + err = -ENOMEM; \ + res = NULL; \ + break; \ + } \ err = first && base ? -EIO : fcn1(config, config, key, &res); \ if (err < 0) { \ if (!base) \ @@ -2415,8 +2422,18 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) if (err < 0) \ break; \ } \ + if (snd_config_get_string(res, &key) < 0) \ + break; \ + if (!first && strcmp(key, old_key) == 0) { \ + SNDERR("key %s refers to itself"); \ + err = -EINVAL; \ + res = NULL; \ + break; \ + } \ + free(old_key); \ first = 0; \ - } while (snd_config_get_string(res, &key) >= 0); \ + } \ + free(old_key); \ if (!res) \ return err; \ if (result) \ |