|
|
417a11 |
diff --git a/src/fsmagic.c b/src/fsmagic.c
|
|
|
417a11 |
index 7200271..1ffe667 100644
|
|
|
417a11 |
--- a/src/fsmagic.c
|
|
|
417a11 |
+++ b/src/fsmagic.c
|
|
|
417a11 |
@@ -124,14 +124,12 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
|
|
|
417a11 |
|
|
|
417a11 |
if (ret) {
|
|
|
417a11 |
if (ms->flags & MAGIC_ERROR) {
|
|
|
417a11 |
- file_error(ms, errno, "cannot stat `%s'", fn);
|
|
|
417a11 |
+ file_error(ms, errno, "cannot stat");
|
|
|
417a11 |
return -1;
|
|
|
417a11 |
}
|
|
|
417a11 |
- if (file_printf(ms, "cannot open `%s' (%s)",
|
|
|
417a11 |
- fn, strerror(errno)) == -1)
|
|
|
417a11 |
+ if (file_printf(ms, "cannot open (%s)", strerror(errno)) == -1)
|
|
|
417a11 |
return -1;
|
|
|
417a11 |
- ms->event_flags |= EVENT_HAD_ERR;
|
|
|
417a11 |
- return -1;
|
|
|
417a11 |
+ return 0;
|
|
|
417a11 |
}
|
|
|
417a11 |
|
|
|
417a11 |
if (!mime) {
|
|
|
417a11 |
diff --git a/src/magic.c b/src/magic.c
|
|
|
417a11 |
index 2b61080..a184a35 100644
|
|
|
417a11 |
--- a/src/magic.c
|
|
|
417a11 |
+++ b/src/magic.c
|
|
|
417a11 |
@@ -417,8 +417,9 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
|
|
417a11 |
ispipe = 1;
|
|
|
417a11 |
} else {
|
|
|
417a11 |
int flags = O_RDONLY|O_BINARY;
|
|
|
417a11 |
+ int okstat = stat(inname, &sb) == 0;
|
|
|
417a11 |
|
|
|
417a11 |
- if (stat(inname, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
|
|
|
417a11 |
+ if (okstat && S_ISFIFO(sb.st_mode)) {
|
|
|
417a11 |
#ifdef O_NONBLOCK
|
|
|
417a11 |
flags |= O_NONBLOCK;
|
|
|
417a11 |
#endif
|
|
|
417a11 |
@@ -427,7 +428,8 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
|
|
417a11 |
|
|
|
417a11 |
errno = 0;
|
|
|
417a11 |
if ((fd = open(inname, flags)) < 0) {
|
|
|
417a11 |
- if (unreadable_info(ms, sb.st_mode, inname) == -1)
|
|
|
417a11 |
+ if (okstat &&
|
|
|
417a11 |
+ unreadable_info(ms, sb.st_mode, inname) == -1)
|
|
|
417a11 |
goto done;
|
|
|
417a11 |
rv = 0;
|
|
|
417a11 |
goto done;
|
|
|
417a11 |
@@ -462,7 +464,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
|
|
417a11 |
|
|
|
417a11 |
} else {
|
|
|
417a11 |
if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
|
|
|
417a11 |
- file_error(ms, errno, "cannot read `%s'", inname);
|
|
|
417a11 |
+ file_error(ms, errno, "cannot read");
|
|
|
417a11 |
goto done;
|
|
|
417a11 |
}
|
|
|
417a11 |
}
|