diff options
author | obrien <obrien@FreeBSD.org> | 2009-05-04 00:37:44 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2009-05-04 00:37:44 +0000 |
commit | a8abfd3eba1e14d222768ebf8316ec02e56af39a (patch) | |
tree | 12756817ab8bc4334652c625c7731c9e7fd0cefc /contrib/file/magic.c | |
parent | 3222e9c2cde262a2a5a46f45f0a1e06623f69433 (diff) | |
parent | 3d89d1fbe920995209cda59ff0fd5096b6471133 (diff) | |
download | FreeBSD-src-a8abfd3eba1e14d222768ebf8316ec02e56af39a.zip FreeBSD-src-a8abfd3eba1e14d222768ebf8316ec02e56af39a.tar.gz |
Merge vendor/file/dist@191739, bringing FILE 5.00 to 8-CURRENT.
Diffstat (limited to 'contrib/file/magic.c')
-rw-r--r-- | contrib/file/magic.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/contrib/file/magic.c b/contrib/file/magic.c index 55dfee1..26b7b86 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 |