aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-27 14:07:13 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-27 14:07:13 +0000
commit2068590dac784041561e7b9bec3872cac4ccf1ed (patch)
tree9f4265b9a3eec1eaa2266e74d0d0b4263ed842bf
parent975c2c2a25023c5977aea221f0d038e0aa4052ef (diff)
Merged revisions 125794 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r125794 | tilghman | 2008-06-27 08:54:13 -0500 (Fri, 27 Jun 2008) | 10 lines 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. ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@125795 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--include/asterisk/lock.h12
-rw-r--r--main/utils.c8
2 files changed, 10 insertions, 10 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 1a294d400..060ddfdcb 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -193,9 +193,9 @@ void ast_remove_lock_info(void *lock_addr);
* 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);
+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) -1
+#define ast_find_lock_info(a,b,c,d,e,f,g,h) -1
#endif
/*!
@@ -206,9 +206,9 @@ int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, cons
*/
#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... */ \
@@ -220,9 +220,9 @@ int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, cons
#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... */ \
diff --git a/main/utils.c b/main/utils.c
index d3f803b28..1a7043573 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -676,7 +676,7 @@ void ast_mark_lock_failed(void *lock_addr)
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;
@@ -697,10 +697,10 @@ int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, cons
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);