[asterisk-bugs] [JIRA] (ASTERISK-25612) Configuration parser handles unsigned integers as signed integers
Gianluca Merlo (JIRA)
noreply at issues.asterisk.org
Sat Dec 5 15:26:33 CST 2015
Gianluca Merlo created ASTERISK-25612:
-----------------------------------------
Summary: Configuration parser handles unsigned integers as signed integers
Key: ASTERISK-25612
URL: https://issues.asterisk.org/jira/browse/ASTERISK-25612
Project: Asterisk
Issue Type: Bug
Security Level: None
Affects Versions: 13.6.0
Reporter: Gianluca Merlo
Hello,
I seem to have stumbled in what seems to be a bug in Asterisk's configuration parser, more specifically it seems that if an option is registered with the unsigned integer type, it is nonetheless handled as if the value should be a signed integer.
To help you reproduce this issue, I can consistently experience it while trying to configure {{res_hep.so}} via its configuration file {{hep.conf}}. One of {{hep.conf}} options is {{capture_id}} which is intended to be an unsigned integer. {{res/res_hep.c}} registers the option on load with
{code}
aco_option_register(&cfg_info, "capture_id", ACO_EXACT, global_options, "0", OPT_UINT_T, 0, STRFLDSET(struct hepv3_global_config, capture_id));
{code}
however, if I configure
{noformat}
capture_id = 2147483648
{noformat}
the module fails to load and I get (logs):
{noformat}
[Dec 5 21:59:16] DEBUG[5547] config.c: extract int from [0] in [-2147483648, 2147483647] gives [0](0)
[Dec 5 21:59:16] DEBUG[5547] config.c: Parsing /etc/asterisk/hep.conf
[Dec 5 21:59:16] DEBUG[5547] config.c: extract int from [2147483648] in [-2147483648, 2147483647] gives [0](1)
[Dec 5 21:59:16] ERROR[5547] config_options.c: Error parsing capture_id=2147483648 at line 31 of
[Dec 5 21:59:16] ERROR[5547] config_options.c: In hep.conf: Processing options for general failed
{noformat}
Regarding the source, and the fix for it, it seems to me that the bug is in the code of {{main/config_options.c}}, in the implementation of {{uint_handler_fn()}}. This functions initializes parser flags as
{code}
unsigned int flags = PARSE_INT32 | opt->flags;
{code}
while it should initialize them as
{code}
unsigned int flags = PARSE_UINT32 | opt->flags;
{code}
I hope my guess is right, and you can confirm and fix it in the next release. Thank you for your assistance.
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list