Patch for asterisk-chan-capi in sarge (again, untested): diff -u asterisk-chan-capi-0.3.5/debian/patches/00list asterisk-chan-capi-0.3.5/debian/patches/00list --- asterisk-chan-capi-0.3.5/debian/patches/00list +++ asterisk-chan-capi-0.3.5/debian/patches/00list @@ -1,0 +2 @@ +02_capi-cmsg2str-mutex only in patch2: unchanged: --- asterisk-chan-capi-0.3.5.orig/debian/patches/02_capi-cmsg2str-mutex.dpatch +++ asterisk-chan-capi-0.3.5/debian/patches/02_capi-cmsg2str-mutex.dpatch @@ -0,0 +1,237 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 02_capi-msg2str-mutex.dpatch by Ben Hutchings <[EMAIL PROTECTED]> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Protect calls to capi_cmsg2str and use of its buffer with a mutex. + [EMAIL PROTECTED]@ +--- asterisk-chan-capi-0.3.5/chan_capi.c~ 2004-08-13 10:07:28.000000000 +0000 ++++ asterisk-chan-capi-0.3.5/chan_capi.c 2007-02-18 14:45:36.000000000 +0000 +@@ -66,6 +66,7 @@ + AST_MUTEX_DEFINE_STATIC(contrlock); + AST_MUTEX_DEFINE_STATIC(capi_send_buffer_lock); + AST_MUTEX_DEFINE_STATIC(capi_put_lock); ++AST_MUTEX_DEFINE_STATIC(capi_cmsg2str_lock); + #else + static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; + static ast_mutex_t iflock = AST_MUTEX_INITIALIZER; +@@ -74,6 +75,7 @@ + static ast_mutex_t contrlock = AST_MUTEX_INITIALIZER; + static ast_mutex_t capi_send_buffer_lock = AST_MUTEX_INITIALIZER; + static ast_mutex_t capi_put_lock = AST_MUTEX_INITIALIZER; ++static ast_mutex_t capi_cmsg2str_lock = AST_MUTEX_INITIALIZER; + #endif + + #ifdef CAPI_ULAW +@@ -1299,7 +1301,9 @@ + return 0; + } + if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_log(LOG_NOTICE,"%s",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); + } + return -1; + } +@@ -1722,7 +1726,9 @@ + if (INFO_IND_INFONUMBER(CMSG) == 0x74) { + strncpy(p->i->owner->exten,capi_number(INFO_IND_INFOELEMENT(CMSG),3),sizeof(p->i->owner->exten)-1); + strncpy(p->i->owner->dnid,capi_number(INFO_IND_INFOELEMENT(CMSG),3),sizeof(p->i->owner->dnid)-1); ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); + } + if (INFO_IND_INFONUMBER(CMSG) == 0x28) { + // ast_sendtext(p->i->owner,capi_number(INFO_IND_INFOELEMENT(CMSG),0)); +@@ -1851,8 +1857,11 @@ + if ((FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(CMSG)[4] == 0x0) && (FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(CMSG)[5] == 0x0)) { + } else { + p->i->state = CAPI_STATE_BCONNECTED; +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + } + } +@@ -1928,8 +1937,11 @@ + + switch (CMSG->Command) { + case CAPI_CONNECT: // only connect_ind are global (not channel specific) +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_log(LOG_NOTICE,"%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + DNID = capi_number(CONNECT_IND_CALLEDPARTYNUMBER(CMSG),1); + if ((DNID && *DNID == 0) || !DNID) { + DNID = emptydnid; +@@ -2074,24 +2086,33 @@ + case CAPI_FACILITY: + PLCI = FACILITY_IND_PLCI(CMSG) & 0xffff; // this is for you eicon + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"FACILITY_IND PLCI=%#x\n",PLCI); + break; + case CAPI_INFO: + PLCI = INFO_IND_PLCI(CMSG); + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"INFO_IND PLCI=%#x INFO# = %#x\n",PLCI,INFO_IND_INFONUMBER(CMSG)); + break; + case CAPI_CONNECT_ACTIVE: + PLCI = CONNECT_ACTIVE_IND_PLCI(CMSG); + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"CONNECT_ACTIVE_IND PLCI=%#x\n",PLCI); + break; +@@ -2099,8 +2120,11 @@ + NCCI = CONNECT_B3_IND_NCCI(CMSG); + PLCI = (NCCI << 16) >> 16; + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"CONNECT_B3_IND NCCI=%#x PLCI=%#x\n",NCCI,PLCI); + break; +@@ -2108,8 +2132,11 @@ + NCCI = CONNECT_B3_IND_NCCI(CMSG); + PLCI = (NCCI << 16) >> 16; + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"CONNECT_B3_ACTIVE_IND NCCI=%#x PLCI=%#x\n",NCCI,PLCI); + break; +@@ -2152,8 +2179,11 @@ + } + } + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"FACILITY_CONF NCCI=%#x INFO=%#x\n",(int)FACILITY_CONF_NCCI(CMSG),FACILITY_CONF_INFO(CMSG)); + break; +@@ -2164,16 +2194,22 @@ + case CAPI_CONNECT: + PLCI = CONNECT_CONF_PLCI(CMSG); + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"CONNECT_CONF PLCI=%#x INFO=%#x MN=%#x\n",PLCI,CONNECT_CONF_INFO(CMSG),CMSG->Messagenumber); + break; + case CAPI_DISCONNECT: + PLCI = DISCONNECT_CONF_PLCI(CMSG); + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"DISCONNECT_CONF PLCI=%#x INFO=%#x MN=%#x\n",PLCI,DISCONNECT_CONF_INFO(CMSG),CMSG->Messagenumber); + break; +@@ -2181,8 +2217,11 @@ + NCCI = DISCONNECT_B3_CONF_NCCI(CMSG); + PLCI = (NCCI << 16) >> 16; + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"DISCONNECT_B3_CONF NCCI=%#x INFO=%#x MN=%#x\n",NCCI,DISCONNECT_B3_CONF_INFO(CMSG),CMSG->Messagenumber); + break; +@@ -2190,16 +2229,22 @@ + NCCI = CONNECT_B3_CONF_NCCI(CMSG); + PLCI = (NCCI << 16) >> 16; + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"CONNECT_B3_CONF PLCI=%#x INFO=%#x MN=%#x\n",PLCI,CONNECT_B3_CONF_INFO(CMSG),CMSG->Messagenumber); + break; + case CAPI_ALERT: + PLCI = ALERT_CONF_PLCI(CMSG); + if (option_verbose > 3) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"ALERT_CONF PLCI=%#x\n",PLCI); + break; +@@ -2207,8 +2252,11 @@ + NCCI = DATA_B3_CONF_NCCI(CMSG); + PLCI = (NCCI << 16) >> 16; + if (option_verbose > 5) { +- if (capidebug) ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); + ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(CMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + } + // ast_log(LOG_ERROR,"DATA_B3_CONF NCCI=%#x PLCI=%#x\n",NCCI,PLCI); + break; +@@ -2245,8 +2293,11 @@ + memset(monCMSG,0,sizeof(_cmsg)); + switch(Info = check_wait_get_cmsg(monCMSG)) { + case 0x0000: +- if (capidebug) +- ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(monCMSG)); ++ if (capidebug) { ++ ast_mutex_lock(&capi_cmsg2str_lock); ++ ast_verbose(VERBOSE_PREFIX_3 "%s\n",capi_cmsg2str(monCMSG)); ++ ast_mutex_unlock(&capi_cmsg2str_lock); ++ } + capi_handle_msg(monCMSG); + break; + case 0x1104: -- END --
-- Ben Hutchings If God had intended Man to program, we'd have been born with serial I/O ports.
signature.asc
Description: This is a digitally signed message part