2016-04-18 15:32:24 +02:00
|
|
|
---
|
|
|
|
src/apprentice.c | 6 +++---
|
|
|
|
src/compress.c | 2 +-
|
|
|
|
src/file.c | 2 +-
|
|
|
|
src/magic.c | 2 +-
|
|
|
|
4 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
|
|
2013-09-30 16:29:55 +02:00
|
|
|
--- src/apprentice.c
|
2018-10-22 10:10:34 +02:00
|
|
|
+++ src/apprentice.c 2018-10-22 07:46:50.986423768 +0000
|
|
|
|
@@ -1154,7 +1154,7 @@ load_1(struct magic_set *ms, int action,
|
2011-11-05 21:03:46 +01:00
|
|
|
ssize_t len;
|
2013-01-22 17:19:33 +01:00
|
|
|
struct magic_entry me;
|
2011-11-05 21:03:46 +01:00
|
|
|
|
|
|
|
- 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'",
|
2018-10-22 10:10:34 +02:00
|
|
|
@@ -3061,7 +3061,7 @@ apprentice_map(struct magic_set *ms, con
|
2011-11-05 21:03:46 +01:00
|
|
|
if (dbname == NULL)
|
2013-01-22 17:19:33 +01:00
|
|
|
goto error;
|
2011-11-05 21:03:46 +01:00
|
|
|
|
|
|
|
- if ((fd = open(dbname, O_RDONLY|O_BINARY)) == -1)
|
|
|
|
+ if ((fd = open(dbname, O_RDONLY|O_BINARY|O_CLOEXEC)) == -1)
|
2013-01-22 17:19:33 +01:00
|
|
|
goto error;
|
2011-11-05 21:03:46 +01:00
|
|
|
|
|
|
|
if (fstat(fd, &st) == -1) {
|
2018-10-22 10:10:34 +02:00
|
|
|
@@ -3198,7 +3198,7 @@ apprentice_compile(struct magic_set *ms,
|
|
|
|
if (dbname == NULL)
|
2011-11-05 21:03:46 +01:00
|
|
|
goto out;
|
|
|
|
|
2018-10-22 10:10:34 +02:00
|
|
|
- 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)
|
2013-01-22 17:19:33 +01:00
|
|
|
{
|
2011-11-05 21:03:46 +01:00
|
|
|
file_error(ms, errno, "cannot open `%s'", dbname);
|
|
|
|
goto out;
|
2013-09-30 16:29:55 +02:00
|
|
|
--- src/compress.c
|
2018-10-22 10:10:34 +02:00
|
|
|
+++ src/compress.c 2018-10-22 07:47:40.645502604 +0000
|
|
|
|
@@ -423,7 +423,7 @@ file_pipe2file(struct magic_set *ms, int
|
2013-01-22 17:19:33 +01:00
|
|
|
{
|
|
|
|
int te;
|
2018-10-22 10:10:34 +02:00
|
|
|
int ou = umask(0);
|
2013-01-22 17:19:33 +01:00
|
|
|
- tfd = mkstemp(buf);
|
|
|
|
+ tfd = mkostemp(buf, O_CLOEXEC);
|
2018-10-22 10:10:34 +02:00
|
|
|
(void)umask(ou);
|
2013-01-22 17:19:33 +01:00
|
|
|
te = errno;
|
|
|
|
(void)unlink(buf);
|
2013-09-30 16:29:55 +02:00
|
|
|
--- src/file.c
|
2018-10-22 10:10:34 +02:00
|
|
|
+++ src/file.c 2018-10-22 07:45:35.907816294 +0000
|
|
|
|
@@ -499,7 +499,7 @@ unwrap(struct magic_set *ms, const char
|
2011-11-05 21:03:46 +01:00
|
|
|
f = stdin;
|
|
|
|
wid = 1;
|
|
|
|
} else {
|
|
|
|
- if ((f = fopen(fn, "r")) == NULL) {
|
|
|
|
+ if ((f = fopen(fn, "re")) == NULL) {
|
2018-06-12 17:26:41 +02:00
|
|
|
file_warn("Cannot open `%s'", fn);
|
2011-11-05 21:03:46 +01:00
|
|
|
return 1;
|
2018-06-12 17:26:41 +02:00
|
|
|
}
|
2013-09-30 16:29:55 +02:00
|
|
|
--- src/magic.c
|
2018-10-22 10:10:34 +02:00
|
|
|
+++ src/magic.c 2018-10-22 07:49:39.471290675 +0000
|
|
|
|
@@ -434,7 +434,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) {
|
|
|
|
int okstat = stat(inname, &sb) == 0;
|