[tor-commits] [tor/master] Made 'auto' keyword in torrc case insensitive
nickm at torproject.org
nickm at torproject.org
Thu Jul 12 13:03:43 UTC 2018
commit abeb07a1bff4f68a3143bb47a6123c0fef83ff79
Author: Kaidan <fishstacks at protonmail.com>
Date: Sun Jul 8 00:15:16 2018 +1000
Made 'auto' keyword in torrc case insensitive
---
changes/ticket26663 | 3 +++
src/app/config/config.c | 2 +-
src/app/config/confparse.c | 2 +-
src/test/test_config.c | 14 ++++++++++++++
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/changes/ticket26663 b/changes/ticket26663
new file mode 100644
index 000000000..6424bddc6
--- /dev/null
+++ b/changes/ticket26663
@@ -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
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 28d2be5ec..2e76dd3cb 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -6992,7 +6992,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);
diff --git a/src/app/config/confparse.c b/src/app/config/confparse.c
index 5b7f54bc6..6fa4fd1ea 100644
--- a/src/app/config/confparse.c
+++ b/src/app/config/confparse.c
@@ -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;
diff --git a/src/test/test_config.c b/src/test/test_config.c
index 596ae0448..2bcdcc4e9 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -4602,6 +4602,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));
More information about the tor-commits
mailing list