diff options
author | Matthew Nicholson <mnicholson@digium.com> | 2010-07-06 19:53:04 +0000 |
---|---|---|
committer | Matthew Nicholson <mnicholson@digium.com> | 2010-07-06 19:53:04 +0000 |
commit | 390d5781cfdf83209dbc064af44d3cded8838c47 (patch) | |
tree | a7a3936d21fbba0ca67908ffcffc84c390f44c76 /res/res_fax.c | |
parent | 41cdf6a720b6e6beca99253a1692b401496faca6 (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: https://origsvn.digium.com/svn/asterisk/trunk@274243 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_fax.c')
-rw-r--r-- | res/res_fax.c | 16 |
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 { |