aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_fax.c
diff options
context:
space:
mode:
authormnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-06 19:53:04 +0000
committermnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-06 19:53:04 +0000
commita6f0b0b18793b6da362d6a20b8f6064d48a9345e (patch)
treea7a3936d21fbba0ca67908ffcffc84c390f44c76 /res/res_fax.c
parent22d5cf2893965214957acc307712144ae280fb13 (diff)
Properly detect and report invalid maxrate and maxrate values in the FAXOPT dialplan function. Also make fax_rate_str_to_int() return an unsigned int and return 0 instead of -1 in the event of an error.
FAX-202 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@274243 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_fax.c')
-rw-r--r--res/res_fax.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/res/res_fax.c b/res/res_fax.c
index 0aedd2dec..b1e8a58dd 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -459,13 +459,13 @@ void ast_fax_log(int level, const char *file, const int line, const char *functi
}
/*! \brief convert a rate string to a rate */
-static int fax_rate_str_to_int(const char *ratestr)
+static unsigned int fax_rate_str_to_int(const char *ratestr)
{
int rate;
if (sscanf(ratestr, "%d", &rate) != 1) {
ast_log(LOG_ERROR, "failed to sscanf '%s' to rate\n", ratestr);
- return -1;
+ return 0;
}
switch (rate) {
case 2400:
@@ -479,7 +479,7 @@ static int fax_rate_str_to_int(const char *ratestr)
return rate;
default:
ast_log(LOG_WARNING, "ignoring invalid rate '%s'. Valid options are {2400 | 4800 | 7200 | 9600 | 12000 | 14400 | 28800 | 33600}\n", ratestr);
- return -1;
+ return 0;
}
}
@@ -2118,14 +2118,14 @@ static int set_config(const char *config_file)
if (!strcasecmp(v->name, "minrate")) {
ast_debug(3, "reading minrate '%s' from configuration file\n", v->value);
- if ((rate = fax_rate_str_to_int(v->value)) == -1) {
+ if ((rate = fax_rate_str_to_int(v->value)) == 0) {
ast_config_destroy(cfg);
return -1;
}
general_options.minrate = rate;
} else if (!strcasecmp(v->name, "maxrate")) {
ast_debug(3, "reading maxrate '%s' from configuration file\n", v->value);
- if ((rate = fax_rate_str_to_int(v->value)) == -1) {
+ if ((rate = fax_rate_str_to_int(v->value)) == 0) {
ast_config_destroy(cfg);
return -1;
}
@@ -2240,8 +2240,14 @@ static int acf_faxopt_write(struct ast_channel *chan, const char *cmd, char *dat
ast_string_field_set(details, localstationid, value);
} else if (!strcasecmp(data, "maxrate")) {
details->maxrate = fax_rate_str_to_int(value);
+ if (!details->maxrate) {
+ details->maxrate = ast_fax_maxrate();
+ }
} else if (!strcasecmp(data, "minrate")) {
details->minrate = fax_rate_str_to_int(value);
+ if (!details->minrate) {
+ details->minrate = ast_fax_minrate();
+ }
} else if ((!strcasecmp(data, "modem")) || (!strcasecmp(data, "modems"))) {
update_modem_bits(&details->modems, value);
} else {