strlen fixes and don't destroy SIP channels that still have pending things on them (bug #1552 et al)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2890 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
3047e6772d
commit
5d7c4bb03e
|
@ -19,6 +19,7 @@
|
||||||
#include <asterisk/module.h>
|
#include <asterisk/module.h>
|
||||||
#include <asterisk/adsi.h>
|
#include <asterisk/adsi.h>
|
||||||
#include <asterisk/options.h>
|
#include <asterisk/options.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -178,7 +179,7 @@ static int process_token(void *out, char *src, int maxlen, int argtype)
|
||||||
maxlen = strlen(src) - 1;
|
maxlen = strlen(src) - 1;
|
||||||
memcpy(out, src, maxlen);
|
memcpy(out, src, maxlen);
|
||||||
((char *)out)[maxlen] = '\0';
|
((char *)out)[maxlen] = '\0';
|
||||||
} else if (strlen(src) && (src[0] == '\\')) {
|
} else if (!ast_strlen_zero(src) && (src[0] == '\\')) {
|
||||||
if (!(argtype & ARG_NUMBER))
|
if (!(argtype & ARG_NUMBER))
|
||||||
return -1;
|
return -1;
|
||||||
/* Octal value */
|
/* Octal value */
|
||||||
|
@ -198,7 +199,7 @@ static int process_token(void *out, char *src, int maxlen, int argtype)
|
||||||
/* Convert */
|
/* Convert */
|
||||||
*((unsigned int *)out) = htonl(*((unsigned int *)out));
|
*((unsigned int *)out) = htonl(*((unsigned int *)out));
|
||||||
}
|
}
|
||||||
} else if ((strlen(src) && isdigit(src[0]))) {
|
} else if ((!ast_strlen_zero(src) && isdigit(src[0]))) {
|
||||||
if (!(argtype & ARG_NUMBER))
|
if (!(argtype & ARG_NUMBER))
|
||||||
return -1;
|
return -1;
|
||||||
/* Hex value */
|
/* Hex value */
|
||||||
|
@ -1363,7 +1364,7 @@ static struct adsi_script *compile_script(char *script)
|
||||||
/* Strip comments */
|
/* Strip comments */
|
||||||
if (c)
|
if (c)
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
if (strlen(buf))
|
if (!ast_strlen_zero(buf))
|
||||||
adsi_process(scr, buf, script, lineno);
|
adsi_process(scr, buf, script, lineno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1540,7 +1541,7 @@ static int adsi_exec(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
int res=0;
|
int res=0;
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
if (!data || !strlen(data))
|
if (!data || ast_strlen_zero(data))
|
||||||
data = "asterisk.adsi";
|
data = "asterisk.adsi";
|
||||||
LOCAL_USER_ADD(u);
|
LOCAL_USER_ADD(u);
|
||||||
if (!adsi_available(chan)) {
|
if (!adsi_available(chan)) {
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <asterisk/app.h>
|
#include <asterisk/app.h>
|
||||||
#include <asterisk/dsp.h>
|
#include <asterisk/dsp.h>
|
||||||
#include <asterisk/musiconhold.h>
|
#include <asterisk/musiconhold.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
#include "../asterisk.h"
|
#include "../asterisk.h"
|
||||||
#include "../astconf.h"
|
#include "../astconf.h"
|
||||||
|
|
||||||
|
@ -1465,7 +1466,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
|
||||||
int pid;
|
int pid;
|
||||||
char *stringp;
|
char *stringp;
|
||||||
AGI agi;
|
AGI agi;
|
||||||
if (!data || !strlen(data)) {
|
if (!data || ast_strlen_zero(data)) {
|
||||||
ast_log(LOG_WARNING, "AGI requires an argument (script)\n");
|
ast_log(LOG_WARNING, "AGI requires an argument (script)\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <asterisk/module.h>
|
#include <asterisk/module.h>
|
||||||
#include <asterisk/app.h>
|
#include <asterisk/app.h>
|
||||||
#include <asterisk/astdb.h>
|
#include <asterisk/astdb.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -63,7 +64,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
|
||||||
char passwd[256];
|
char passwd[256];
|
||||||
char *opts;
|
char *opts;
|
||||||
char *prompt;
|
char *prompt;
|
||||||
if (!data || !strlen(data)) {
|
if (!data || ast_strlen_zero(data)) {
|
||||||
ast_log(LOG_WARNING, "Authenticate requires an argument(password)\n");
|
ast_log(LOG_WARNING, "Authenticate requires an argument(password)\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -108,14 +109,14 @@ static int auth_exec(struct ast_channel *chan, void *data)
|
||||||
char buf[256] = "";
|
char buf[256] = "";
|
||||||
while(!feof(f)) {
|
while(!feof(f)) {
|
||||||
fgets(buf, sizeof(buf), f);
|
fgets(buf, sizeof(buf), f);
|
||||||
if (!feof(f) && strlen(buf)) {
|
if (!feof(f) && !ast_strlen_zero(buf)) {
|
||||||
buf[strlen(buf) - 1] = '\0';
|
buf[strlen(buf) - 1] = '\0';
|
||||||
if (strlen(buf) && !strcmp(passwd, buf))
|
if (!ast_strlen_zero(buf) && !strcmp(passwd, buf))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if (strlen(buf) && !strcmp(passwd, buf))
|
if (!ast_strlen_zero(buf) && !strcmp(passwd, buf))
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
ast_log(LOG_WARNING, "Unable to open file '%s' for authentication: %s\n", password, strerror(errno));
|
ast_log(LOG_WARNING, "Unable to open file '%s' for authentication: %s\n", password, strerror(errno));
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <asterisk/parking.h>
|
#include <asterisk/parking.h>
|
||||||
#include <asterisk/musiconhold.h>
|
#include <asterisk/musiconhold.h>
|
||||||
#include <asterisk/callerid.h>
|
#include <asterisk/callerid.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -201,7 +202,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
||||||
*allowdisconnect = o->allowdisconnect;
|
*allowdisconnect = o->allowdisconnect;
|
||||||
}
|
}
|
||||||
} else if (o->chan && (o->chan == winner)) {
|
} else if (o->chan && (o->chan == winner)) {
|
||||||
if (strlen(o->chan->call_forward)) {
|
if (!ast_strlen_zero(o->chan->call_forward)) {
|
||||||
char tmpchan[256];
|
char tmpchan[256];
|
||||||
/* Before processing channel, go ahead and check for forwarding */
|
/* Before processing channel, go ahead and check for forwarding */
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
|
@ -235,7 +236,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
||||||
}
|
}
|
||||||
if (o->chan->rdnis)
|
if (o->chan->rdnis)
|
||||||
free(o->chan->rdnis);
|
free(o->chan->rdnis);
|
||||||
if (strlen(in->macroexten))
|
if (!ast_strlen_zero(in->macroexten))
|
||||||
o->chan->rdnis = strdup(in->macroexten);
|
o->chan->rdnis = strdup(in->macroexten);
|
||||||
else
|
else
|
||||||
o->chan->rdnis = strdup(in->exten);
|
o->chan->rdnis = strdup(in->exten);
|
||||||
|
@ -445,7 +446,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
timeout = NULL;
|
timeout = NULL;
|
||||||
if (!peers || !strlen(peers)) {
|
if (!peers || ast_strlen_zero(peers)) {
|
||||||
ast_log(LOG_WARNING, "Dial argument takes format (technology1/number1&technology2/number2...|optional timeout)\n");
|
ast_log(LOG_WARNING, "Dial argument takes format (technology1/number1&technology2/number2...|optional timeout)\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -581,7 +582,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||||
}
|
}
|
||||||
if (resetcdr && chan->cdr)
|
if (resetcdr && chan->cdr)
|
||||||
ast_cdr_reset(chan->cdr, 0);
|
ast_cdr_reset(chan->cdr, 0);
|
||||||
if (!strlen(privdb) && privacy) {
|
if (ast_strlen_zero(privdb) && privacy) {
|
||||||
/* If privdb is not specified and we are using privacy, copy from extension */
|
/* If privdb is not specified and we are using privacy, copy from extension */
|
||||||
strncpy(privdb, chan->exten, sizeof(privdb) - 1);
|
strncpy(privdb, chan->exten, sizeof(privdb) - 1);
|
||||||
}
|
}
|
||||||
|
@ -658,7 +659,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||||
cur = rest;
|
cur = rest;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strlen(tmp->chan->call_forward)) {
|
if (!ast_strlen_zero(tmp->chan->call_forward)) {
|
||||||
char tmpchan[256];
|
char tmpchan[256];
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Forwarding call to '%s@%s'\n", tmp->chan->call_forward, tmp->chan->context);
|
ast_verbose(VERBOSE_PREFIX_3 "Forwarding call to '%s@%s'\n", tmp->chan->call_forward, tmp->chan->context);
|
||||||
|
@ -721,7 +722,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||||
tmp->chan->callerid = NULL;
|
tmp->chan->callerid = NULL;
|
||||||
/* Copy language from incoming to outgoing */
|
/* Copy language from incoming to outgoing */
|
||||||
strcpy(tmp->chan->language, chan->language);
|
strcpy(tmp->chan->language, chan->language);
|
||||||
if (!strlen(tmp->chan->musicclass))
|
if (ast_strlen_zero(tmp->chan->musicclass))
|
||||||
strncpy(tmp->chan->musicclass, chan->musicclass, sizeof(tmp->chan->musicclass) - 1);
|
strncpy(tmp->chan->musicclass, chan->musicclass, sizeof(tmp->chan->musicclass) - 1);
|
||||||
if (chan->ani)
|
if (chan->ani)
|
||||||
tmp->chan->ani = strdup(chan->ani);
|
tmp->chan->ani = strdup(chan->ani);
|
||||||
|
@ -768,7 +769,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||||
cur = rest;
|
cur = rest;
|
||||||
} while(cur);
|
} while(cur);
|
||||||
|
|
||||||
if (timeout && strlen(timeout)) {
|
if (timeout && !ast_strlen_zero(timeout)) {
|
||||||
to = atoi(timeout);
|
to = atoi(timeout);
|
||||||
if (to > 0)
|
if (to > 0)
|
||||||
to *= 1000;
|
to *= 1000;
|
||||||
|
@ -808,7 +809,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* JDG: sendurl */
|
/* JDG: sendurl */
|
||||||
if( url && strlen(url) && ast_channel_supports_html(peer) ) {
|
if( url && !ast_strlen_zero(url) && ast_channel_supports_html(peer) ) {
|
||||||
ast_log(LOG_DEBUG, "app_dial: sendurl=%s.\n", url);
|
ast_log(LOG_DEBUG, "app_dial: sendurl=%s.\n", url);
|
||||||
ast_channel_sendurl( peer, url );
|
ast_channel_sendurl( peer, url );
|
||||||
} /* /JDG */
|
} /* /JDG */
|
||||||
|
|
|
@ -651,6 +651,8 @@ static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp)
|
||||||
if (cur->retransid > -1)
|
if (cur->retransid > -1)
|
||||||
ast_sched_del(sched, cur->retransid);
|
ast_sched_del(sched, cur->retransid);
|
||||||
cur->retransid = -1;
|
cur->retransid = -1;
|
||||||
|
/* Schedule destruction in 15000ms just in case */
|
||||||
|
sip_scheddestroy(p, 15000);
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6173,7 +6175,7 @@ restartsearch:
|
||||||
sip = iflist;
|
sip = iflist;
|
||||||
while(sip) {
|
while(sip) {
|
||||||
ast_mutex_lock(&sip->lock);
|
ast_mutex_lock(&sip->lock);
|
||||||
if (sip->needdestroy && (!sip->packets || (sip->packets->retransid == -1))) {
|
if (sip->needdestroy && !sip->packets) {
|
||||||
ast_mutex_unlock(&sip->lock);
|
ast_mutex_unlock(&sip->lock);
|
||||||
__sip_destroy(sip, 1);
|
__sip_destroy(sip, 1);
|
||||||
goto restartsearch;
|
goto restartsearch;
|
||||||
|
|
Reference in New Issue