70 lines
2.1 KiB
Diff
70 lines
2.1 KiB
Diff
---
|
|
src/apprentice.c | 6 +++---
|
|
src/compress.c | 2 +-
|
|
src/file.c | 2 +-
|
|
src/magic.c | 2 +-
|
|
4 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
|
--- src/apprentice.c
|
|
+++ src/apprentice.c 2019-05-27 08:53:31.057488035 +0000
|
|
@@ -1154,7 +1154,7 @@ load_1(struct magic_set *ms, int action,
|
|
ssize_t len;
|
|
struct magic_entry me;
|
|
|
|
- FILE *f = fopen(ms->file = fn, "r");
|
|
+ FILE *f = fopen(ms->file = fn, "re");
|
|
if (f == NULL) {
|
|
if (errno != ENOENT)
|
|
file_error(ms, errno, "cannot read magic file `%s'",
|
|
@@ -3062,7 +3062,7 @@ apprentice_map(struct magic_set *ms, con
|
|
if (dbname == NULL)
|
|
goto error;
|
|
|
|
- if ((fd = open(dbname, O_RDONLY|O_BINARY)) == -1)
|
|
+ if ((fd = open(dbname, O_RDONLY|O_BINARY|O_CLOEXEC)) == -1)
|
|
goto error;
|
|
|
|
if (fstat(fd, &st) == -1) {
|
|
@@ -3199,7 +3199,7 @@ apprentice_compile(struct magic_set *ms,
|
|
if (dbname == NULL)
|
|
goto out;
|
|
|
|
- if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1)
|
|
+ if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY|O_CLOEXEC, 0644)) == -1)
|
|
{
|
|
file_error(ms, errno, "cannot open `%s'", dbname);
|
|
goto out;
|
|
--- src/compress.c
|
|
+++ src/compress.c 2019-05-27 08:53:31.057488035 +0000
|
|
@@ -435,7 +435,7 @@ file_pipe2file(struct magic_set *ms, int
|
|
{
|
|
int te;
|
|
mode_t ou = umask(0);
|
|
- tfd = mkstemp(buf);
|
|
+ tfd = mkostemp(buf, O_CLOEXEC);
|
|
(void)umask(ou);
|
|
te = errno;
|
|
(void)unlink(buf);
|
|
--- src/file.c
|
|
+++ src/file.c 2019-05-27 08:53:31.057488035 +0000
|
|
@@ -498,7 +498,7 @@ unwrap(struct magic_set *ms, const char
|
|
f = stdin;
|
|
wid = 1;
|
|
} else {
|
|
- if ((f = fopen(fn, "r")) == NULL) {
|
|
+ if ((f = fopen(fn, "re")) == NULL) {
|
|
file_warn("Cannot open `%s'", fn);
|
|
return 1;
|
|
}
|
|
--- src/magic.c
|
|
+++ src/magic.c 2019-05-27 09:00:04.010005617 +0000
|
|
@@ -436,7 +436,7 @@ file_or_fd(struct magic_set *ms, const c
|
|
_setmode(STDIN_FILENO, O_BINARY);
|
|
#endif
|
|
if (inname != NULL) {
|
|
- int flags = O_RDONLY|O_BINARY|O_NONBLOCK;
|
|
+ int flags = O_RDONLY|O_BINARY|O_NONBLOCK|O_CLOEXEC;
|
|
errno = 0;
|
|
if ((fd = open(inname, flags)) < 0) {
|
|
okstat = stat(inname, &sb) == 0;
|