mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 14:51:11 +01:00
Allow wildcarded mapaddress targets in controller MAPADDRESS command
This commit is contained in:
parent
0b3f5ca11f
commit
23f2e37ff7
2 changed files with 18 additions and 4 deletions
4
changes/bug6244
Normal file
4
changes/bug6244
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
o Major bugfixes:
|
||||||
|
- Allow wildcarded mapaddress targets to be specified on the controlport.
|
||||||
|
Partial fix for bug 6244; bugfix on 0.2.3.9-alpha.
|
||||||
|
|
|
@ -1313,6 +1313,17 @@ handle_control_takeownership(control_connection_t *conn, uint32_t len,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return true iff <b>addr</b> is unusable as a mapaddress target because of
|
||||||
|
* containing funny characters. */
|
||||||
|
static int
|
||||||
|
address_is_invalid_mapaddress_target(const char *addr)
|
||||||
|
{
|
||||||
|
if (!strcmpstart(addr, "*."))
|
||||||
|
return address_is_invalid_destination(addr+2, 1);
|
||||||
|
else
|
||||||
|
return address_is_invalid_destination(addr, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/** Called when we get a MAPADDRESS command; try to bind all listed addresses,
|
/** Called when we get a MAPADDRESS command; try to bind all listed addresses,
|
||||||
* and report success or failure. */
|
* and report success or failure. */
|
||||||
static int
|
static int
|
||||||
|
@ -1331,14 +1342,13 @@ handle_control_mapaddress(control_connection_t *conn, uint32_t len,
|
||||||
reply = smartlist_new();
|
reply = smartlist_new();
|
||||||
smartlist_split_string(lines, body, " ",
|
smartlist_split_string(lines, body, " ",
|
||||||
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
|
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
|
||||||
SMARTLIST_FOREACH(lines, char *, line,
|
SMARTLIST_FOREACH_BEGIN(lines, char *, line) {
|
||||||
{
|
|
||||||
tor_strlower(line);
|
tor_strlower(line);
|
||||||
smartlist_split_string(elts, line, "=", 0, 2);
|
smartlist_split_string(elts, line, "=", 0, 2);
|
||||||
if (smartlist_len(elts) == 2) {
|
if (smartlist_len(elts) == 2) {
|
||||||
const char *from = smartlist_get(elts,0);
|
const char *from = smartlist_get(elts,0);
|
||||||
const char *to = smartlist_get(elts,1);
|
const char *to = smartlist_get(elts,1);
|
||||||
if (address_is_invalid_destination(to, 1)) {
|
if (address_is_invalid_mapaddress_target(to)) {
|
||||||
smartlist_add_asprintf(reply,
|
smartlist_add_asprintf(reply,
|
||||||
"512-syntax error: invalid address '%s'", to);
|
"512-syntax error: invalid address '%s'", to);
|
||||||
log_warn(LD_CONTROL,
|
log_warn(LD_CONTROL,
|
||||||
|
@ -1370,7 +1380,7 @@ handle_control_mapaddress(control_connection_t *conn, uint32_t len,
|
||||||
}
|
}
|
||||||
SMARTLIST_FOREACH(elts, char *, cp, tor_free(cp));
|
SMARTLIST_FOREACH(elts, char *, cp, tor_free(cp));
|
||||||
smartlist_clear(elts);
|
smartlist_clear(elts);
|
||||||
});
|
} SMARTLIST_FOREACH_END(line);
|
||||||
SMARTLIST_FOREACH(lines, char *, cp, tor_free(cp));
|
SMARTLIST_FOREACH(lines, char *, cp, tor_free(cp));
|
||||||
smartlist_free(lines);
|
smartlist_free(lines);
|
||||||
smartlist_free(elts);
|
smartlist_free(elts);
|
||||||
|
|
Loading…
Add table
Reference in a new issue