Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
userhosts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
userhosts
Commits
1daeace3
Commit
1daeace3
authored
Aug 28, 2014
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not call va_arg when open O_DIRECTORY flag is set.
Also, fix build on systems without O_TMPFILE.
parent
0681899b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
userhosts.c
userhosts.c
+9
-1
No files found.
userhosts.c
View file @
1daeace3
...
...
@@ -29,6 +29,14 @@
#define ORIGINAL_HOSTS_PATH "/etc/hosts"
/* Standard O_TMPFILE includes O_DIRECTORY bit, but we do not want to call
* va_arg if O_DIRECTORY is set alone. Hence, define a "purer" O_TMPFILE. */
#define PURE_O_TMPFILE (020000000)
/* And sanity-check when O_TMPFILE is defined. */
#if defined(O_TMPFILE) && (O_TMPFILE & PURE_O_TMPFILE) == 0
#error PURE_O_TMPFILE is incorrectly defined
#endif
static
int
(
*
original_open
)(
const
char
*
,
int
,
...);
static
FILE
*
(
*
original_fopen
)(
const
char
*
,
const
char
*
);
static
const
char
*
replacement_hosts
;
...
...
@@ -59,7 +67,7 @@ static void __attribute__ ((constructor)) init(void) {
int
open
(
const
char
*
__file
,
int
__oflag
,
...)
{
if
(
strcmp
(
__file
,
ORIGINAL_HOSTS_PATH
)
==
0
)
__file
=
replacement_hosts
;
if
(
__oflag
&
(
O_CREAT
|
O_TMPFILE
))
{
if
(
__oflag
&
(
O_CREAT
|
PURE_
O_TMPFILE
))
{
va_list
ap
;
mode_t
mode
;
...
...
Write
Preview
Markdown
is supported
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