summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2007-09-02 14:37:53 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2007-09-02 14:37:53 +0000
commit87044d37a00fff3a8ded9cd561492874cdfde4b5 (patch)
treec92aafc248a1297fd5e0ab54edb76417eb18a382 /main
parent1bfe10997b8cd79015c49dba761ead9d623b1555 (diff)
We shouldn't use a filename blindly without checking to make sure it's unused first
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81430 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/config.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/main/config.c b/main/config.c
index 7a44685b9..5889a0358 100644
--- a/main/config.c
+++ b/main/config.c
@@ -235,12 +235,14 @@ struct ast_config_include *ast_include_new(struct ast_config *conf, const char *
instances is possible, I'd have
to create a new master for each instance. */
struct ast_config_include *inc;
+ struct stat statbuf;
inc = ast_include_find(conf, included_file);
- if (inc)
- {
- inc->inclusion_count++;
- snprintf(real_included_file_name, real_included_file_name_size, "%s~~%d", included_file, inc->inclusion_count);
+ if (inc) {
+ do {
+ inc->inclusion_count++;
+ snprintf(real_included_file_name, real_included_file_name_size, "%s~~%d", included_file, inc->inclusion_count);
+ } while (stat(real_included_file_name, &statbuf) == 0);
ast_log(LOG_WARNING,"'%s', line %d: Same File included more than once! This data will be saved in %s if saved back to disk.\n", from_file, from_lineno, real_included_file_name);
} else
*real_included_file_name = 0;