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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@125793 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2008-06-27 13:45:03 +00:00
parent 226a47ccfd
commit db4ae54745
2 changed files with 8 additions and 8 deletions

View File

@@ -186,9 +186,9 @@ void ast_remove_lock_info(void *lock_addr);
* be preserved as to what location originally acquired the lock. * be preserved as to what location originally acquired the lock.
*/ */
#if !defined(LOW_MEMORY) #if !defined(LOW_MEMORY)
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);
#else #else
#define ast_find_lock_info(a,b,c,d,e) -1 #define ast_find_lock_info(a,b,c,d,e,f,g,h) -1
#endif #endif
/*! /*!
@@ -199,9 +199,9 @@ int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, cons
*/ */
#define DEADLOCK_AVOIDANCE(lock) \ #define DEADLOCK_AVOIDANCE(lock) \
do { \ do { \
const char *__filename, *__func, *__mutex_name; \ char __filename[80], __func[80], __mutex_name[80]; \
int __lineno; \ 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); \ ast_mutex_unlock(lock); \
usleep(1); \ usleep(1); \
if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \ if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \

View File

@@ -676,7 +676,7 @@ void ast_mark_lock_failed(void *lock_addr)
pthread_mutex_unlock(&lock_info->lock); 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; struct thr_lock_info *lock_info;
int i = 0; int i = 0;
@@ -697,10 +697,10 @@ int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, cons
return -1; 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; *lineno = lock_info->locks[i].line_num;
*func = lock_info->locks[i].func; ast_copy_string(func, lock_info->locks[i].func, func_size);
*mutex_name = lock_info->locks[i].lock_name; ast_copy_string(mutex_name, lock_info->locks[i].lock_name, mutex_name_size);
pthread_mutex_unlock(&lock_info->lock); pthread_mutex_unlock(&lock_info->lock);