summaryrefslogtreecommitdiff
path: root/main/app.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-07-10 15:04:58 -0400
committerCorey Farrell <git@cfware.com>2017-07-13 11:46:57 -0400
commitdf49ad2528627ff75af937a3430e09569e99caeb (patch)
tree2b9752bc1176e5847618de1c781d3187b600cccc /main/app.c
parentec182b6d509fe8ef965ac0c11147db33f53e6ca9 (diff)
core: Add PARSE_TIMELEN support to ast_parse_arg and ACO.
This adds support for parsing timelen values from config files. This includes support for all flags which apply to PARSE_INT32. Support for this parser is added to ACO via the OPT_TIMELEN_T option type. Fixes an issue where extra characters provided to ast_app_parse_timelen were ignored, they now cause an error. Testing is included. ASTERISK-27117 #close Change-Id: I6b333feca7e3f83b4ef5bf2636fc0fd613742554
Diffstat (limited to 'main/app.c')
-rw-r--r--main/app.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/main/app.c b/main/app.c
index ee7cef26b..85dc87d3e 100644
--- a/main/app.c
+++ b/main/app.c
@@ -3069,19 +3069,32 @@ int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen uni
case 'h':
case 'H':
unit = TIMELEN_HOURS;
+ if (u[1] != '\0') {
+ return -1;
+ }
break;
case 's':
case 'S':
unit = TIMELEN_SECONDS;
+ if (u[1] != '\0') {
+ return -1;
+ }
break;
case 'm':
case 'M':
if (toupper(u[1]) == 'S') {
unit = TIMELEN_MILLISECONDS;
+ if (u[2] != '\0') {
+ return -1;
+ }
} else if (u[1] == '\0') {
unit = TIMELEN_MINUTES;
+ } else {
+ return -1;
}
break;
+ default:
+ return -1;
}
}