Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
55d8b8e5
Commit
55d8b8e5
authored
11 years ago
by
Cristian Toader
Browse files
Options
Downloads
Patches
Plain Diff
fixed bug where sandbox_getaddrinfo() would fail when -Sandbox is 0
parent
b4b0eddd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/address.c
+1
-1
1 addition, 1 deletion
src/common/address.c
src/common/sandbox.c
+26
-4
26 additions, 4 deletions
src/common/sandbox.c
src/common/sandbox.h
+2
-1
2 additions, 1 deletion
src/common/sandbox.h
with
29 additions
and
6 deletions
src/common/address.c
+
1
−
1
View file @
55d8b8e5
...
...
@@ -235,7 +235,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
,
&
res
);
err
=
sandbox_getaddrinfo
(
name
,
hints
,
&
res
);
if
(
!
err
)
{
best
=
NULL
;
for
(
res_p
=
res
;
res_p
;
res_p
=
res_p
->
ai_next
)
{
...
...
This diff is collapsed.
Click to expand it.
src/common/sandbox.c
+
26
−
4
View file @
55d8b8e5
...
...
@@ -54,6 +54,7 @@
#include
<time.h>
#include
<poll.h>
static
int
sandbox_active
=
0
;
static
sandbox_cfg_t
*
filter_dynamic
=
NULL
;
static
sb_addr_info_t
*
sb_addr_info
=
NULL
;
...
...
@@ -948,7 +949,8 @@ sandbox_cfg_allow_execve_array(sandbox_cfg_t **cfg, ...)
}
int
sandbox_getaddrinfo
(
const
char
*
name
,
struct
addrinfo
**
res
)
sandbox_getaddrinfo
(
const
char
*
name
,
struct
addrinfo
hints
,
struct
addrinfo
**
res
)
{
sb_addr_info_t
*
el
;
...
...
@@ -956,18 +958,31 @@ sandbox_getaddrinfo(const char *name, struct addrinfo **res)
for
(
el
=
sb_addr_info
;
el
;
el
=
el
->
next
)
{
if
(
!
strcmp
(
el
->
name
,
name
))
{
*
res
=
(
struct
addrinfo
*
)
malloc
(
sizeof
(
struct
addrinfo
));
*
res
=
(
struct
addrinfo
*
)
malloc
(
sizeof
(
struct
addrinfo
));
if
(
!
res
)
{
return
-
2
;
}
memcpy
(
*
res
,
el
->
info
,
sizeof
(
struct
addrinfo
));
return
0
;
}
}
if
(
!
sandbox_active
)
{
if
(
getaddrinfo
(
name
,
NULL
,
&
hints
,
res
))
{
log_err
(
LD_BUG
,
"(Sandbox) getaddrinfo failed!"
);
return
-
1
;
}
return
0
;
}
// getting here means something went wrong
log_err
(
LD_BUG
,
"(Sandbox) failed to get address %s!"
,
name
);
if
(
*
res
)
{
free
(
*
res
);
res
=
NULL
;
}
return
-
1
;
}
...
...
@@ -1069,7 +1084,14 @@ install_syscall_filter(sandbox_cfg_t* cfg)
goto
end
;
}
rc
=
seccomp_load
(
ctx
);
// loading the seccomp2 filter
if
((
rc
=
seccomp_load
(
ctx
)))
{
log_err
(
LD_BUG
,
"(Sandbox) failed to load!"
);
goto
end
;
}
// marking the sandbox as active
sandbox_active
=
1
;
end:
seccomp_release
(
ctx
);
...
...
This diff is collapsed.
Click to expand it.
src/common/sandbox.h
+
2
−
1
View file @
55d8b8e5
...
...
@@ -133,7 +133,8 @@ typedef struct {
int
sandbox_add_addrinfo
(
const
char
*
addr
);
/** Replacement for getaddrinfo(), using pre-recorded results. */
int
sandbox_getaddrinfo
(
const
char
*
name
,
struct
addrinfo
**
res
);
int
sandbox_getaddrinfo
(
const
char
*
name
,
struct
addrinfo
hints
,
struct
addrinfo
**
res
);
/** Use <b>fd</b> to log non-survivable sandbox violations. */
void
sandbox_set_debugging_fd
(
int
fd
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment