Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
HardenedBSD
pkg
Commits
fba0a6ec
Commit
fba0a6ec
authored
May 21, 2021
by
Baptiste Daroussin
Browse files
Close as soon as possible fd
parent
08f33a08
Changes
1
Hide whitespace changes
Inline
Side-by-side
libpkg/lua.c
View file @
fba0a6ec
...
...
@@ -296,18 +296,20 @@ lua_pkg_filecmp(lua_State *L)
lua_pushinteger
(
L
,
2
);
return
(
1
);
}
buf1
=
mmap
(
NULL
,
s1
.
st_size
,
PROT_READ
,
MAP_SHARED
,
fd1
,
0
);
close
(
fd1
);
if
(
buf1
==
NULL
)
{
lua_pushinteger
(
L
,
-
1
);
return
(
1
);
}
fd2
=
openat
(
rootfd
,
RELATIVE_PATH
(
file2
),
O_RDONLY
,
DEFFILEMODE
);
if
(
fd2
==
-
1
)
{
lua_pushinteger
(
L
,
2
);
return
(
1
);
}
buf1
=
mmap
(
NULL
,
s1
.
st_size
,
PROT_READ
,
MAP_SHARED
,
fd1
,
0
);
if
(
buf1
==
NULL
)
{
lua_pushinteger
(
L
,
-
1
);
return
(
1
);
}
buf2
=
mmap
(
NULL
,
s2
.
st_size
,
PROT_READ
,
MAP_SHARED
,
fd2
,
0
);
close
(
fd2
);
if
(
buf2
==
NULL
)
{
lua_pushinteger
(
L
,
-
1
);
return
(
1
);
...
...
@@ -317,8 +319,6 @@ lua_pkg_filecmp(lua_State *L)
munmap
(
buf1
,
s1
.
st_size
);
munmap
(
buf2
,
s2
.
st_size
);
close
(
fd1
);
close
(
fd2
);
lua_pushinteger
(
L
,
ret
);
return
(
1
);
...
...
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