aboutsummaryrefslogtreecommitdiff
path: root/contrib/file/magic.c
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2009-05-04 00:37:44 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2009-05-04 00:37:44 +0000
commit7dbb948b5f00eabb81904e9db0aa9fc712939aca (patch)
tree12756817ab8bc4334652c625c7731c9e7fd0cefc /contrib/file/magic.c
parent8ee6f90a0c45383950152583c7fd62172e27bb73 (diff)
parent4f3dd34290f174adbda2b9668cc6b6c554ae9bb0 (diff)
downloadsrc-7dbb948b5f00eabb81904e9db0aa9fc712939aca.tar.gz
src-7dbb948b5f00eabb81904e9db0aa9fc712939aca.zip
Merge vendor/file/dist@191739, bringing FILE 5.00 to 8-CURRENT.
Notes
Notes: svn path=/head/; revision=191771
Diffstat (limited to 'contrib/file/magic.c')
-rw-r--r--contrib/file/magic.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/contrib/file/magic.c b/contrib/file/magic.c
index 55dfee1b35b2..26b7b864d832 100644
--- a/contrib/file/magic.c
+++ b/contrib/file/magic.c
@@ -26,15 +26,16 @@
*/
#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: magic.c,v 1.59 2009/02/03 20:27:51 christos Exp $")
+#endif /* lint */
+
#include "magic.h"
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/param.h> /* for MAXPATHLEN */
-#include <sys/stat.h>
#ifdef QUICK
#include <sys/mman.h>
#endif
@@ -64,10 +65,6 @@
#include "patchlevel.h"
-#ifndef lint
-FILE_RCSID("@(#)$File: magic.c,v 1.54 2008/07/25 23:30:32 rrt Exp $")
-#endif /* lint */
-
#ifndef PIPE_BUF
/* Get the PIPE_BUF from pathconf */
#ifdef _PC_PIPE_BUF
@@ -116,7 +113,7 @@ magic_open(int flags)
if ((ms->c.li = CAST(struct level_info *, malloc(len))) == NULL)
goto free;
- ms->haderr = 0;
+ ms->event_flags = 0;
ms->error = -1;
ms->mlist = NULL;
ms->file = "unknown";
@@ -229,7 +226,7 @@ close_and_restore(const struct magic_set *ms, const char *name, int fd,
#elif defined(HAVE_UTIME_H) || defined(HAVE_SYS_UTIME_H)
struct utimbuf utbuf;
- (void)memset(utbuf, 0, sizeof(utbuf));
+ (void)memset(&utbuf, 0, sizeof(utbuf));
utbuf.actime = sb->st_atime;
utbuf.modtime = sb->st_mtime;
(void) utime(name, &utbuf); /* don't care if loses */
@@ -302,8 +299,9 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
if ((fd = open(inname, flags)) < 0) {
#ifdef __CYGWIN__
/* FIXME: Do this with EXEEXT from autotools */
- char *tmp = alloca(strlen(inname) + 5);
- (void)strcat(strcpy(tmp, inname), ".exe");
+ size_t len = strlen(inname) + 5;
+ char *tmp = alloca(len);
+ (void)strlcat(strlcpy(tmp, inname, len), ".exe", len);
if ((fd = open(tmp, flags)) < 0) {
#endif
if (unreadable_info(ms, sb.st_mode,
@@ -385,13 +383,13 @@ magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
public const char *
magic_error(struct magic_set *ms)
{
- return ms->haderr ? ms->o.buf : NULL;
+ return (ms->event_flags & EVENT_HAD_ERR) ? ms->o.buf : NULL;
}
public int
magic_errno(struct magic_set *ms)
{
- return ms->haderr ? ms->error : 0;
+ return (ms->event_flags & EVENT_HAD_ERR) ? ms->error : 0;
}
public int