~ubuntu-branches/debian/squeeze/asterisk-chan-capi/squeeze

« back to all changes in this revision

Viewing changes to debian/patches/02_capi-cmsg2str-mutex.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings
  • Date: 2007-03-07 01:58:53 UTC
  • mfrom: (3.1.3 feisty)
  • Revision ID: james.westby@ubuntu.com-20070307015853-yw0ov095k4fx2rza
Tags: 0.7.1-1.1
* Non-maintainer upload
* Protect calls to capi_cmsg2str and use of its buffer with a mutex.
  (Closes: #411293)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 02_capi-msg2str-mutex.dpatch by Ben Hutchings <ben@decadent.org.uk>
 
3
##
 
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.
 
6
 
 
7
@DPATCH@
 
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
 
10
@@ -167,6 +167,8 @@
 
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);
 
16
  *
 
17
  *
 
18
  *  ** the PBX will call the callback functions with 
 
19
@@ -180,6 +182,7 @@
 
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);
 
25
 
 
26
 static int capi_capability = AST_FORMAT_ALAW;
 
27
@@ -402,6 +405,7 @@
 
28
                return -1;
 
29
        }
 
30
 
 
31
+       cc_mutex_lock(&capi_cmsg2str_lock);
 
32
        if (error) {
 
33
                cc_log(LOG_ERROR, "CAPI error sending %s (NCCI=%#x) (error=%#x %s)\n",
 
34
                        capi_cmsg2str(CMSG), (unsigned int)HEADER_CID(CMSG),
 
35
@@ -415,6 +419,7 @@
 
36
                        cc_verbose(4, 1, "%s\n", capi_cmsg2str(CMSG));
 
37
                }
 
38
        }
 
39
+       cc_mutex_unlock(&capi_cmsg2str_lock);
 
40
 
 
41
        return error;
 
42
 }
 
43
@@ -3972,12 +3977,14 @@
 
44
        unsigned short wInfo = 0xffff;
 
45
        struct capi_pvt *i = find_interface_by_plci(PLCI);
 
46
 
 
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));
 
51
        } else {
 
52
                cc_verbose(4, 1, "%s\n", capi_cmsg2str(CMSG));
 
53
        }
 
54
+       cc_mutex_unlock(&capi_cmsg2str_lock);
 
55
 
 
56
        if (i != NULL)
 
57
                cc_mutex_lock(&i->lock);