1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 02_capi-msg2str-mutex.dpatch by Ben Hutchings <ben@decadent.org.uk>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: Protect calls to capi_cmsg2str and use of its buffer with a mutex.
8
--- asterisk-chan-capi-0.7.1/chan_capi.c~ 2006-10-08 13:38:27.000000000 +0000
9
+++ asterisk-chan-capi-0.7.1/chan_capi.c 2007-02-17 22:26:32.000000000 +0000
11
* 4. cc_mutex_lock(&messagenumber_lock);
12
* 5. cc_mutex_lock(&usecnt_lock);
13
* 6. cc_mutex_lock(&capi_put_lock);
14
+ * 7. cc_mutex_lock(&capi_cmsg2str_lock);
15
+ * 8. cc_mutex_lock(&verbose_lock);
18
* ** the PBX will call the callback functions with
20
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
21
AST_MUTEX_DEFINE_STATIC(iflock);
22
AST_MUTEX_DEFINE_STATIC(capi_put_lock);
23
+AST_MUTEX_DEFINE_STATIC(capi_cmsg2str_lock);
24
AST_MUTEX_DEFINE_STATIC(verbose_lock);
26
static int capi_capability = AST_FORMAT_ALAW;
31
+ cc_mutex_lock(&capi_cmsg2str_lock);
33
cc_log(LOG_ERROR, "CAPI error sending %s (NCCI=%#x) (error=%#x %s)\n",
34
capi_cmsg2str(CMSG), (unsigned int)HEADER_CID(CMSG),
36
cc_verbose(4, 1, "%s\n", capi_cmsg2str(CMSG));
39
+ cc_mutex_unlock(&capi_cmsg2str_lock);
43
@@ -3972,12 +3977,14 @@
44
unsigned short wInfo = 0xffff;
45
struct capi_pvt *i = find_interface_by_plci(PLCI);
47
+ cc_mutex_lock(&capi_cmsg2str_lock);
48
if ((wCmd == CAPI_P_IND(DATA_B3)) ||
49
(wCmd == CAPI_P_CONF(DATA_B3))) {
50
cc_verbose(7, 1, "%s\n", capi_cmsg2str(CMSG));
52
cc_verbose(4, 1, "%s\n", capi_cmsg2str(CMSG));
54
+ cc_mutex_unlock(&capi_cmsg2str_lock);
57
cc_mutex_lock(&i->lock);