Merge remote-tracking branch 'imnotbad/bug26663'

This commit is contained in:
Nick Mathewson 2018-07-12 08:59:23 -04:00
commit a7ec493d88
4 changed files with 19 additions and 2 deletions

3
changes/ticket26663 Normal file
View File

@ -0,0 +1,3 @@
o Minor features(config):
- Parsing of "auto" keyword in torrc is now case insensitive.
Fixes bug 26663; bugfix on 0.3.5.0-alpha

View File

@ -7001,7 +7001,7 @@ parse_port_config(smartlist_t *out,
port = 0;
else
port = 1;
} else if (!strcmp(addrport, "auto")) {
} else if (!strcasecmp(addrport, "auto")) {
port = CFG_AUTO_PORT;
int af = tor_addr_parse(&addr, defaultaddr);
tor_assert(af >= 0);

View File

@ -267,7 +267,7 @@ config_assign_value(const config_format_t *fmt, void *options,
break;
case CONFIG_TYPE_AUTOBOOL:
if (!strcmp(c->value, "auto"))
if (!strcasecmp(c->value, "auto"))
*(int *)lvalue = -1;
else if (!strcmp(c->value, "0"))
*(int *)lvalue = 0;

View File

@ -4637,6 +4637,20 @@ test_config_parse_port_config__ports__ports_given(void *data)
tor_addr_parse(&addr, "127.0.0.46");
tt_assert(tor_addr_eq(&port_cfg->addr, &addr))
// Test success with a port of auto in mixed case
config_free_lines(config_port_valid); config_port_valid = NULL;
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "AuTo");
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
"127.0.0.46", 0, 0);
tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1);
port_cfg = (port_cfg_t *)smartlist_get(slout, 0);
tt_int_op(port_cfg->port, OP_EQ, CFG_AUTO_PORT);
tor_addr_parse(&addr, "127.0.0.46");
tt_assert(tor_addr_eq(&port_cfg->addr, &addr))
// Test success with parsing both an address and an auto port
config_free_lines(config_port_valid); config_port_valid = NULL;
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));