[asterisk-commits] tilghman: trunk r81430 - /trunk/main/config.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Sep 2 09:37:54 CDT 2007


Author: tilghman
Date: Sun Sep  2 09:37:53 2007
New Revision: 81430

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81430
Log:
We shouldn't use a filename blindly without checking to make sure it's unused first

Modified:
    trunk/main/config.c

Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=81430&r1=81429&r2=81430
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Sun Sep  2 09:37:53 2007
@@ -235,12 +235,14 @@
        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;




More information about the asterisk-commits mailing list