From: Christos Zoulas Date: Wed, 26 Sep 2007 20:45:26 +0000 (+0000) Subject: recent changes X-Git-Tag: FILE5_05~593 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=82bcf84fbcb2c2c7f9939b8ea1259823c0a3a1f8;p=file recent changes --- diff --git a/ChangeLog b/ChangeLog index 80385988..9ee1078b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-09-26 4:45 Christos Zoulas + + * Fix regression in elf reading code where the core name was + not being printed. + + * Don't convert NUL's to spaces in {l,b}estring16 (Daniel Dawson) + 2007-08-19 6:30 Christos Zoulas * Make mime format consistent so that it can diff --git a/magic/Magdir/archive b/magic/Magdir/archive index 045ee7e4..65d5d136 100644 --- a/magic/Magdir/archive +++ b/magic/Magdir/archive @@ -734,3 +734,9 @@ # From "Nelson A. de Oliveira" 0 string MPQ\032 MoPaQ (MPQ) archive + +# From: Dirk Jagdmann +# xar archive format: http://code.google.com/p/xar/ +0 string xar! xar archive +>6 beshort x - version %ld + diff --git a/magic/Magdir/audio b/magic/Magdir/audio index e1999888..5664d009 100644 --- a/magic/Magdir/audio +++ b/magic/Magdir/audio @@ -556,3 +556,6 @@ # From: Matthew Flaschen 0 string #EXTM3U M3U playlist text +# From: "Mateus Caruccio" +# guitar pro v3,4,5 from http://filext.com/file-extension/gp3 +0 string \030FICHIER\ GUITAR\ PRO\ v3. Guitar Pro Ver. 3 Tablature diff --git a/magic/Magdir/console b/magic/Magdir/console index 40a3c2e4..775472d4 100644 --- a/magic/Magdir/console +++ b/magic/Magdir/console @@ -191,3 +191,64 @@ 0 string PPF10 Playstation Patch File version 1.0 >5 byte 0 \b, Simple Encoding >6 string x \b, description: %s + +# From: Daniel Dawson +# SNES9x .smv "movie" file format. +0 string SMV\x1A SNES9x input recording +>0x4 lelong x \b, version %d +# version 4 is latest so far +>0x4 lelong <5 +>>0x8 ledate x \b, recorded at %s +>>0xc lelong >0 \b, rerecorded %d times +>>0x10 lelong x \b, %d frames long +>>0x14 byte >0 \b, data for controller(s): +>>>0x14 byte &0x1 #1 +>>>0x14 byte &0x2 #2 +>>>0x14 byte &0x4 #3 +>>>0x14 byte &0x8 #4 +>>>0x14 byte &0x10 #5 +>>0x15 byte ^0x1 \b, begins from snapshot +>>0x15 byte &0x1 \b, begins from reset +>>0x15 byte ^0x2 \b, NTSC standard +>>0x15 byte &0x2 \b, PAL standard +>>0x17 byte &0x1 \b, settings: +# WIP1Timing not used as of version 4 +>>>0x4 lelong <4 +>>>>0x17 byte &0x2 WIP1Timing +>>>0x17 byte &0x4 Left+Right +>>>0x17 byte &0x8 VolumeEnvX +>>>0x17 byte &0x10 FakeMute +>>>0x17 byte &0x20 SyncSound +# New flag as of version 4 +>>>0x4 lelong >3 +>>>>0x17 byte &0x80 NoCPUShutdown +>>0x4 lelong <4 +>>>0x18 lelong >0x23 +>>>>0x20 leshort !0 +>>>>>0x20 lestring16 x \b, metadata: "%s" +>>0x4 lelong >3 +>>>0x24 byte >0 \b, port 1: +>>>>0x24 byte 1 joypad +>>>>0x24 byte 2 mouse +>>>>0x24 byte 3 SuperScope +>>>>0x24 byte 4 Justifier +>>>>0x24 byte 5 multitap +>>>0x24 byte >0 \b, port 2: +>>>>0x25 byte 1 joypad +>>>>0x25 byte 2 mouse +>>>>0x25 byte 3 SuperScope +>>>>0x25 byte 4 Justifier +>>>>0x25 byte 5 multitap +>>>0x18 lelong >0x43 +>>>>0x40 leshort !0 +>>>>>0x40 lestring16 x \b, metadata: "%s" +>>0x17 byte &0x40 \b, ROM: +>>>(0x18.l-26) lelong x CRC32 0x%08x +>>>(0x18.l-23) string x "%s" + +# From: "Nelson A. de Oliveira" +# .w3g +0 string Warcraft\ III\ recorded\ game %s +# .w3m +0 string HM3W Warcraft III map file + diff --git a/magic/Magdir/pdf b/magic/Magdir/pdf index a1aef133..e90214ef 100644 --- a/magic/Magdir/pdf +++ b/magic/Magdir/pdf @@ -5,3 +5,9 @@ 0 string %PDF- PDF document >5 byte x \b, version %c >7 byte x \b.%c + +# From: Nick Schmalenberger +# Forms Data Format +0 string %FDF- FDF text +>5 byte x \b, version %c +>7 byte x \b.%c diff --git a/magic/Magdir/sgi b/magic/Magdir/sgi index 43cb63fb..f7de1380 100644 --- a/magic/Magdir/sgi +++ b/magic/Magdir/sgi @@ -15,19 +15,22 @@ >20 lelong 0 log volume #0 >20 lelong >0 log volume #%ld >24 string >\0 host: %s -0 string PCPFolio PCP +0 string PCPFolio PCP >9 string Version: Archive Folio >18 string >\0 (V.%s) 0 string #pmchart PCP pmchart view >9 string Version >17 string >\0 (V%-3.3s) +0 string #kmchart PCP kmchart view +>9 string Version +>17 string >\0 (V.%s) 0 string pmview PCP pmview config >7 string Version >15 string >\0 (V%-3.3s) 0 string #pmlogger PCP pmlogger config >10 string Version >18 string >\0 (V%1.1s) -0 string PcPh PCP Help +0 string PcPh PCP Help >4 string 1 Index >4 string 2 Text >5 string >\0 (V.%1.1s) diff --git a/src/magic.c b/src/magic.c index 14feca7d..b7b38cda 100644 --- a/src/magic.c +++ b/src/magic.c @@ -63,7 +63,7 @@ #include "patchlevel.h" #ifndef lint -FILE_RCSID("@(#)$File: magic.c,v 1.42 2007/08/19 03:45:08 christos Exp $") +FILE_RCSID("@(#)$File: magic.c,v 1.43 2007/09/26 20:45:26 christos Exp $") #endif /* lint */ #ifdef __EMX__ @@ -76,6 +76,9 @@ private void free_mlist(struct mlist *); private void close_and_restore(const struct magic_set *, const char *, int, const struct stat *); private int info_from_stat(struct magic_set *, mode_t); +#ifndef COMPILE_ONLY +private const char *file_or_fd(struct magic_set *, const char *, int); +#endif #ifndef STDIN_FILENO #define STDIN_FILENO 0 @@ -230,13 +233,28 @@ close_and_restore(const struct magic_set *ms, const char *name, int fd, } #ifndef COMPILE_ONLY + +/* + * find type of descriptor + */ +public const char * +magic_descriptor(struct magic_set *ms, int fd) +{ + return file_or_fd(ms, NULL, fd); +} + /* * find type of named file */ public const char * magic_file(struct magic_set *ms, const char *inname) { - int fd = 0; + return file_or_fd(ms, inname, STDIN_FILENO); +} + +private const char * +file_or_fd(struct magic_set *ms, const char *inname, int fd) +{ int rv = -1; unsigned char *buf; struct stat sb; @@ -265,7 +283,6 @@ magic_file(struct magic_set *ms, const char *inname) } if (inname == NULL) { - fd = STDIN_FILENO; if (fstat(fd, &sb) == 0 && S_ISFIFO(sb.st_mode)) ispipe = 1; } else { @@ -279,16 +296,16 @@ magic_file(struct magic_set *ms, const char *inname) errno = 0; if ((fd = open(inname, flags)) < 0) { #ifdef __CYGWIN__ - char *tmp = alloca(strlen(inname) + 5); - (void)strcat(strcpy(tmp, inname), ".exe"); - if ((fd = open(tmp, flags)) < 0) { + char *tmp = alloca(strlen(inname) + 5); + (void)strcat(strcpy(tmp, inname), ".exe"); + if ((fd = open(tmp, flags)) < 0) { #endif - if (info_from_stat(ms, sb.st_mode) == -1) - goto done; - rv = 0; - goto done; + if (info_from_stat(ms, sb.st_mode) == -1) + goto done; + rv = 0; + goto done; #ifdef __CYGWIN__ - } + } #endif } #ifdef O_NONBLOCK @@ -332,7 +349,8 @@ magic_file(struct magic_set *ms, const char *inname) goto done; } else if (nbytes == 1) { if (file_printf(ms, (ms->flags & MAGIC_MIME) ? - "application/octet-stream" : "very short file (no magic)") == -1) + "application/octet-stream" : "very short file (no magic)") + == -1) goto done; } else { (void)memset(buf + nbytes, 0, SLOP); /* NUL terminate */ diff --git a/src/magic.h b/src/magic.h index 39fa2e11..483cac3f 100644 --- a/src/magic.h +++ b/src/magic.h @@ -59,6 +59,7 @@ magic_t magic_open(int); void magic_close(magic_t); const char *magic_file(magic_t, const char *); +const char *magic_descriptor(magic_t, int); const char *magic_buffer(magic_t, const void *, size_t); const char *magic_error(magic_t); diff --git a/src/readelf.h b/src/readelf.h index 20a4d0fc..40d26e75 100644 --- a/src/readelf.h +++ b/src/readelf.h @@ -190,12 +190,6 @@ typedef struct { Elf64_Off sh_entsize; } Elf64_Shdr; -/* Notes used in ET_CORE */ -#define NT_PRSTATUS 1 -#define NT_PRFPREG 2 -#define NT_PRPSINFO 3 -#define NT_TASKSTRUCT 4 - #define NT_NETBSD_CORE_PROCINFO 1 /* Note header in a PT_NOTE section */ @@ -211,10 +205,12 @@ typedef struct { Elf64_Word n_type; } Elf64_Nhdr; +/* Notes used in ET_CORE */ #define NT_PRSTATUS 1 #define NT_PRFPREG 2 #define NT_PRPSINFO 3 #define NT_PRXREG 4 +#define NT_TASKSTRUCT 4 #define NT_PLATFORM 5 #define NT_AUXV 6