2013-04-02 11:14:57 +02:00
|
|
|
Index: src/apprentice.c
|
|
|
|
===================================================================
|
|
|
|
--- src/apprentice.c.orig
|
|
|
|
+++ src/apprentice.c
|
|
|
|
@@ -930,7 +930,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'",
|
2013-04-02 11:14:57 +02:00
|
|
|
@@ -2584,7 +2584,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) {
|
2013-04-02 11:14:57 +02:00
|
|
|
@@ -2696,7 +2696,7 @@ apprentice_compile(struct magic_set *ms,
|
2011-11-05 21:03:46 +01:00
|
|
|
if (dbname == NULL)
|
|
|
|
goto out;
|
|
|
|
|
2013-01-22 17:19:33 +01: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)
|
|
|
|
{
|
2011-11-05 21:03:46 +01:00
|
|
|
file_error(ms, errno, "cannot open `%s'", dbname);
|
|
|
|
goto out;
|
2013-04-02 11:14:57 +02:00
|
|
|
Index: src/compress.c
|
|
|
|
===================================================================
|
|
|
|
--- src/compress.c.orig
|
|
|
|
+++ src/compress.c
|
2013-01-22 17:19:33 +01:00
|
|
|
@@ -252,7 +252,7 @@ file_pipe2file(struct magic_set *ms, int
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
int te;
|
|
|
|
- tfd = mkstemp(buf);
|
|
|
|
+ tfd = mkostemp(buf, O_CLOEXEC);
|
|
|
|
te = errno;
|
|
|
|
(void)unlink(buf);
|
|
|
|
errno = te;
|
2013-04-02 11:14:57 +02:00
|
|
|
Index: src/file.c
|
|
|
|
===================================================================
|
|
|
|
--- src/file.c.orig
|
|
|
|
+++ src/file.c
|
2013-01-22 17:19:33 +01:00
|
|
|
@@ -390,7 +390,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) {
|
|
|
|
(void)fprintf(stderr, "%s: Cannot open `%s' (%s).\n",
|
|
|
|
progname, fn, strerror(errno));
|
|
|
|
return 1;
|
2013-04-02 11:14:57 +02:00
|
|
|
Index: src/magic.c
|
|
|
|
===================================================================
|
|
|
|
--- src/magic.c.orig
|
|
|
|
+++ src/magic.c
|
2013-01-22 17:19:33 +01:00
|
|
|
@@ -369,7 +369,7 @@ file_or_fd(struct magic_set *ms, const c
|
|
|
|
if (fstat(fd, &sb) == 0 && S_ISFIFO(sb.st_mode))
|
|
|
|
ispipe = 1;
|
|
|
|
} else {
|
|
|
|
- int flags = O_RDONLY|O_BINARY;
|
|
|
|
+ int flags = O_RDONLY|O_BINARY|O_CLOEXEC;
|
|
|
|
|
|
|
|
if (stat(inname, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
|
|
|
|
#ifdef O_NONBLOCK
|