[asterisk-commits] tilghman: trunk r125794 - in /trunk: ./ include/asterisk/lock.h main/utils.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 27 08:54:13 CDT 2008


Author: tilghman
Date: Fri Jun 27 08:54:13 2008
New Revision: 125794

URL: http://svn.digium.com/view/asterisk?view=rev&rev=125794
Log:
Merged revisions 125793 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r125793 | tilghman | 2008-06-27 08:45:03 -0500 (Fri, 27 Jun 2008) | 2 lines

In this debugging function, copy to a buffer instead of using potentially unsafe pointers.

........

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/lock.h
    trunk/main/utils.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/lock.h?view=diff&rev=125794&r1=125793&r2=125794
==============================================================================
--- trunk/include/asterisk/lock.h (original)
+++ trunk/include/asterisk/lock.h Fri Jun 27 08:54:13 2008
@@ -250,9 +250,9 @@
  * be preserved as to what location originally acquired the lock.
  */
 #if !defined(LOW_MEMORY)
-int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, const char **func, const char **mutex_name);
-#else
-#define ast_find_lock_info(a,b,c,d,e) -1
+int ast_find_lock_info(void *lock_addr, char *filename, size_t filename_size, int *lineno, char *func, size_t func_size, char *mutex_name, size_t mutex_name_size);
+#else
+#define ast_find_lock_info(a,b,c,d,e,f,g,h) -1
 #endif
 
 /*!
@@ -263,9 +263,9 @@
  */
 #define CHANNEL_DEADLOCK_AVOIDANCE(chan) \
 	do { \
-		const char *__filename, *__func, *__mutex_name; \
+		char __filename[80], __func[80], __mutex_name[80]; \
 		int __lineno; \
-		int __res = ast_find_lock_info(&chan->lock_dont_use, &__filename, &__lineno, &__func, &__mutex_name); \
+		int __res = ast_find_lock_info(&chan->lock_dont_use, __filename, sizeof(__filename), &__lineno, __func, sizeof(__func), __mutex_name, sizeof(__mutex_name)); \
 		ast_channel_unlock(chan); \
 		usleep(1); \
 		if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \
@@ -277,9 +277,9 @@
 
 #define DEADLOCK_AVOIDANCE(lock) \
 	do { \
-		const char *__filename, *__func, *__mutex_name; \
+		char __filename[80], __func[80], __mutex_name[80]; \
 		int __lineno; \
-		int __res = ast_find_lock_info(lock, &__filename, &__lineno, &__func, &__mutex_name); \
+		int __res = ast_find_lock_info(lock, __filename, sizeof(__filename), &__lineno, __func, sizeof(__func), __mutex_name, sizeof(__mutex_name)); \
 		ast_mutex_unlock(lock); \
 		usleep(1); \
 		if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \
@@ -291,9 +291,9 @@
 
 #define DLA_UNLOCK(lock) \
 	do { \
-		const char *__filename, *__func, *__mutex_name; \
+		char __filename[80], __func[80], __mutex_name[80]; \
 		int __lineno; \
-		int __res = ast_find_lock_info(lock, &__filename, &__lineno, &__func, &__mutex_name); \
+		int __res = ast_find_lock_info(lock, __filename, sizeof(__filename), &__lineno, __func, sizeof(__func), __mutex_name, sizeof(__mutex_name)); \
 		ast_mutex_unlock(lock);
 
 #define DLA_LOCK(lock) \

Modified: trunk/main/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/main/utils.c?view=diff&rev=125794&r1=125793&r2=125794
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Fri Jun 27 08:54:13 2008
@@ -692,7 +692,7 @@
 	pthread_mutex_unlock(&lock_info->lock);
 }
 
-int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, const char **func, const char **mutex_name)
+int ast_find_lock_info(void *lock_addr, char *filename, size_t filename_size, int *lineno, char *func, size_t func_size, char *mutex_name, size_t mutex_name_size)
 {
 	struct thr_lock_info *lock_info;
 	int i = 0;
@@ -713,10 +713,10 @@
 		return -1;
 	}
 
-	*filename = lock_info->locks[i].file;
+	ast_copy_string(filename, lock_info->locks[i].file, filename_size);
 	*lineno = lock_info->locks[i].line_num;
-	*func = lock_info->locks[i].func;
-	*mutex_name = lock_info->locks[i].lock_name;
+	ast_copy_string(func, lock_info->locks[i].func, func_size);
+	ast_copy_string(mutex_name, lock_info->locks[i].lock_name, mutex_name_size);
 
 	pthread_mutex_unlock(&lock_info->lock);
 




More information about the asterisk-commits mailing list