diff options
author | jpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-07-21 15:34:21 +0000 |
---|---|---|
committer | jpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-07-21 15:34:21 +0000 |
commit | e58358baf898002b6b92855dc45c8032feee2cba (patch) | |
tree | a826617beaa6cd1bcaf577f16d11dcae90424414 /channels/chan_dahdi.c | |
parent | 9d0252b7202164964c7332bd08869c05d096d098 (diff) |
Merged revisions 132425 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r132425 | jpeeler | 2008-07-21 10:33:13 -0500 (Mon, 21 Jul 2008) | 2 lines
make buffers config option (chan_dahdi.conf) parsing safer and added logging in case of failure
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@132426 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_dahdi.c')
-rw-r--r-- | channels/chan_dahdi.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index d00f7103c..3ca6b53f1 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -13583,7 +13583,6 @@ static void process_echocancel(struct dahdi_chan_conf *confp, const char *data, static int process_dahdi(struct dahdi_chan_conf *confp, struct ast_variable *v, int reload, int skipchannels) { struct dahdi_pvt *tmp; - const char *tempstr; /* temporary string for parsing the dring number, buffers policy */ int y; int found_pseudo = 0; char dahdichan[MAX_CHANLIST_LEN] = {}; @@ -13605,17 +13604,24 @@ static int process_dahdi(struct dahdi_chan_conf *confp, struct ast_variable *v, if (build_channels(confp, iscrv, v->value, reload, v->lineno, &found_pseudo)) return -1; } else if (!strcasecmp(v->name, "buffers")) { - char policy[8]; - tempstr = v->value; - sscanf(tempstr, "%d,%s", &confp->chan.buf_no, policy); + int res; + char policy[8] = ""; + res = sscanf(v->value, "%d,%s", &confp->chan.buf_no, policy); + if (res != 2) { + ast_log(LOG_WARNING, "Parsing buffers option data failed, using defaults.\n"); + confp->chan.buf_no = numbufs; + continue; + } if (confp->chan.buf_no < 0) confp->chan.buf_no = numbufs; if (!strcasecmp(policy, "full")) { confp->chan.buf_policy = DAHDI_POLICY_WHEN_FULL; } else if (!strcasecmp(policy, "half")) { confp->chan.buf_policy = DAHDI_POLICY_IMMEDIATE /*HALF_FULL*/; - } else { + } else if (!strcasecmp(policy, "immediate")) { confp->chan.buf_policy = DAHDI_POLICY_IMMEDIATE; + } else { + ast_log(LOG_WARNING, "Invalid policy name given (%s).\n", policy); } } else if (!strcasecmp(v->name, "dahdichan")) { ast_copy_string(dahdichan, v->value, sizeof(dahdichan)); @@ -13636,14 +13642,11 @@ static int process_dahdi(struct dahdi_chan_conf *confp, struct ast_variable *v, } else if (!strcasecmp(v->name, "dring3range")) { confp->chan.drings.ringnum[2].range = atoi(v->value); } else if (!strcasecmp(v->name, "dring1")) { - tempstr = v->value; - sscanf(tempstr, "%d,%d,%d", &confp->chan.drings.ringnum[0].ring[0], &confp->chan.drings.ringnum[0].ring[1], &confp->chan.drings.ringnum[0].ring[2]); + sscanf(v->value, "%d,%d,%d", &confp->chan.drings.ringnum[0].ring[0], &confp->chan.drings.ringnum[0].ring[1], &confp->chan.drings.ringnum[0].ring[2]); } else if (!strcasecmp(v->name, "dring2")) { - tempstr = v->value; - sscanf(tempstr,"%d,%d,%d", &confp->chan.drings.ringnum[1].ring[0], &confp->chan.drings.ringnum[1].ring[1], &confp->chan.drings.ringnum[1].ring[2]); + sscanf(v->value,"%d,%d,%d", &confp->chan.drings.ringnum[1].ring[0], &confp->chan.drings.ringnum[1].ring[1], &confp->chan.drings.ringnum[1].ring[2]); } else if (!strcasecmp(v->name, "dring3")) { - tempstr = v->value; - sscanf(tempstr, "%d,%d,%d", &confp->chan.drings.ringnum[2].ring[0], &confp->chan.drings.ringnum[2].ring[1], &confp->chan.drings.ringnum[2].ring[2]); + sscanf(v->value, "%d,%d,%d", &confp->chan.drings.ringnum[2].ring[0], &confp->chan.drings.ringnum[2].ring[1], &confp->chan.drings.ringnum[2].ring[2]); } else if (!strcasecmp(v->name, "usecallerid")) { confp->chan.use_callerid = ast_true(v->value); } else if (!strcasecmp(v->name, "cidsignalling")) { |