Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ZerXes
Tor
Commits
03283c00
Commit
03283c00
authored
Jul 09, 2018
by
Nick Mathewson
🐛
Browse files
Merge remote-tracking branch 'rl1987/bug26525'
parents
47859e11
439b528f
Changes
6
Hide whitespace changes
Inline
Side-by-side
changes/bug26525
0 → 100644
View file @
03283c00
o Minor bugfixes (code quality):
- Rename sandbox_getaddrinfo() and other functions to no longer
misleadingly suggest that they are sandbox-only. Fixes bug
26525; bugfix on 0.2.7.1-alpha.
src/core/mainloop/main.c
View file @
03283c00
...
...
@@ -3677,7 +3677,7 @@ tor_free_all(int postfork)
routerparse_free_all
();
ext_orport_free_all
();
control_free_all
();
sandbox
_free_getaddrinfo_cache
();
tor
_free_getaddrinfo_cache
();
protover_free_all
();
bridges_free_all
();
consdiffmgr_free_all
();
...
...
@@ -3899,7 +3899,7 @@ init_addrinfo(void)
// host name to sandbox
gethostname
(
hname
,
sizeof
(
hname
));
sandbox
_add_addrinfo
(
hname
);
tor
_add_addrinfo
(
hname
);
}
static
sandbox_cfg_t
*
...
...
src/lib/net/address.c
View file @
03283c00
...
...
@@ -277,7 +277,7 @@ tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr))
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_family
=
family
;
hints
.
ai_socktype
=
SOCK_STREAM
;
err
=
sandbox
_getaddrinfo
(
name
,
NULL
,
&
hints
,
&
res
);
err
=
tor
_getaddrinfo
(
name
,
NULL
,
&
hints
,
&
res
);
/* The check for 'res' here shouldn't be necessary, but it makes static
* analysis tools happy. */
if
(
!
err
&&
res
)
{
...
...
@@ -306,7 +306,7 @@ tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr))
&
((
struct
sockaddr_in6
*
)
best
->
ai_addr
)
->
sin6_addr
);
result
=
0
;
}
sandbox
_freeaddrinfo
(
res
);
tor
_freeaddrinfo
(
res
);
return
result
;
}
return
(
err
==
EAI_AGAIN
)
?
1
:
-
1
;
...
...
src/lib/net/resolve.c
View file @
03283c00
...
...
@@ -121,16 +121,16 @@ sandbox_disable_getaddrinfo_cache(void)
}
void
sandbox
_freeaddrinfo
(
struct
addrinfo
*
ai
)
tor
_freeaddrinfo
(
struct
addrinfo
*
ai
)
{
if
(
sandbox_getaddrinfo_cache_disabled
)
freeaddrinfo
(
ai
);
}
int
sandbox
_getaddrinfo
(
const
char
*
name
,
const
char
*
servname
,
const
struct
addrinfo
*
hints
,
struct
addrinfo
**
res
)
tor
_getaddrinfo
(
const
char
*
name
,
const
char
*
servname
,
const
struct
addrinfo
*
hints
,
struct
addrinfo
**
res
)
{
int
err
;
struct
cached_getaddrinfo_item_t
search
,
*
item
;
...
...
@@ -191,7 +191,7 @@ sandbox_getaddrinfo(const char *name, const char *servname,
}
int
sandbox
_add_addrinfo
(
const
char
*
name
)
tor
_add_addrinfo
(
const
char
*
name
)
{
struct
addrinfo
*
res
;
struct
addrinfo
hints
;
...
...
@@ -204,16 +204,16 @@ sandbox_add_addrinfo(const char *name)
hints
.
ai_family
=
families
[
i
];
res
=
NULL
;
(
void
)
sandbox
_getaddrinfo
(
name
,
NULL
,
&
hints
,
&
res
);
(
void
)
tor
_getaddrinfo
(
name
,
NULL
,
&
hints
,
&
res
);
if
(
res
)
sandbox
_freeaddrinfo
(
res
);
tor
_freeaddrinfo
(
res
);
}
return
0
;
}
void
sandbox
_free_getaddrinfo_cache
(
void
)
tor
_free_getaddrinfo_cache
(
void
)
{
cached_getaddrinfo_item_t
**
next
,
**
item
,
*
this
;
...
...
@@ -229,7 +229,7 @@ sandbox_free_getaddrinfo_cache(void)
}
void
sandbox
_make_getaddrinfo_cache_active
(
void
)
tor
_make_getaddrinfo_cache_active
(
void
)
{
sandbox_getaddrinfo_is_active
=
1
;
}
...
...
src/lib/net/resolve.h
View file @
03283c00
...
...
@@ -22,27 +22,24 @@ MOCK_DECL(int,tor_lookup_hostname,(const char *name, uint32_t *addr));
struct
addrinfo
;
#ifdef USE_SANDBOX_GETADDRINFO
/** Pre-calls getaddrinfo in order to pre-record result. */
int
sandbox
_add_addrinfo
(
const
char
*
addr
);
int
tor
_add_addrinfo
(
const
char
*
addr
);
// XXXX rename these. They are named as though they were sandbox-only,
// XXXX but in fact they're the only allowed entry point to getaddrinfo.
// XXXX They don't invoke the sandbox code; they only have an internal cache.
struct
addrinfo
;
/** Replacement for getaddrinfo(), using pre-recorded results. */
int
sandbox
_getaddrinfo
(
const
char
*
name
,
const
char
*
servname
,
int
tor
_getaddrinfo
(
const
char
*
name
,
const
char
*
servname
,
const
struct
addrinfo
*
hints
,
struct
addrinfo
**
res
);
void
sandbox
_freeaddrinfo
(
struct
addrinfo
*
addrinfo
);
void
sandbox
_free_getaddrinfo_cache
(
void
);
void
sandbox
_make_getaddrinfo_cache_active
(
void
);
void
tor
_freeaddrinfo
(
struct
addrinfo
*
addrinfo
);
void
tor
_free_getaddrinfo_cache
(
void
);
void
tor
_make_getaddrinfo_cache_active
(
void
);
#else
/* !(defined(USE_SANDBOX_GETADDRINFO)) */
#define
sandbox
_getaddrinfo(name, servname, hints, res) \
#define
tor
_getaddrinfo(name, servname, hints, res) \
getaddrinfo((name),(servname), (hints),(res))
#define
sandbox
_add_addrinfo(name) \
#define
tor
_add_addrinfo(name) \
((void)(name))
#define
sandbox
_freeaddrinfo(addrinfo) \
#define
tor
_freeaddrinfo(addrinfo) \
freeaddrinfo((addrinfo))
#define
sandbox
_free_getaddrinfo_cache()
#define
tor
_free_getaddrinfo_cache()
#endif
/* defined(USE_SANDBOX_GETADDRINFO) */
void
sandbox_disable_getaddrinfo_cache
(
void
);
...
...
src/lib/sandbox/sandbox.c
View file @
03283c00
...
...
@@ -1552,7 +1552,7 @@ install_syscall_filter(sandbox_cfg_t* cfg)
// marking the sandbox as active
sandbox_active
=
1
;
sandbox
_make_getaddrinfo_cache_active
();
tor
_make_getaddrinfo_cache_active
();
end:
seccomp_release
(
ctx
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment