diff options
author | Terry Wilson <twilson@digium.com> | 2012-08-16 23:08:40 +0000 |
---|---|---|
committer | Terry Wilson <twilson@digium.com> | 2012-08-16 23:08:40 +0000 |
commit | 69dc8e3adb8d1255a1ca088472001dc3b27d069f (patch) | |
tree | 6c33da70229a03a4040df2829f107fba25ae01a7 /main/config.c | |
parent | 34265d52654ddb2171a10a1b67bdfa4eb10906e1 (diff) |
Handle integer over/under-flow in ast_parse_args
The strtol family of functions will return *_MIN/*_MAX on overflow. To
detect when an overflow has happened, errno must be set to 0 before
calling the function, then checked afterward.
(closes issue ASTERISK-20120)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2073/
........
Merged revisions 371392 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 371398 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 371399 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371400 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/config.c')
-rw-r--r-- | main/config.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/main/config.c b/main/config.c index 9abc6020d..336f51e39 100644 --- a/main/config.c +++ b/main/config.c @@ -2827,8 +2827,9 @@ int ast_parse_arg(const char *arg, enum ast_parse_flags flags, error = 1; goto int32_done; } + errno = 0; x = strtol(arg, &endptr, 0); - if (*endptr || x < INT32_MIN || x > INT32_MAX) { + if (*endptr || errno || x < INT32_MIN || x > INT32_MAX) { /* Parse error, or type out of int32_t bounds */ error = 1; goto int32_done; @@ -2881,8 +2882,9 @@ int32_done: error = 1; goto uint32_done; } + errno = 0; x = strtoul(arg, &endptr, 0); - if (*endptr || x > UINT32_MAX) { + if (*endptr || errno || x > UINT32_MAX) { error = 1; goto uint32_done; } |