Skip to content

Commit

Permalink
libmagic: upgrade to 5.14
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Apr 24, 2013
1 parent a1cc743 commit bf172ac
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 83 deletions.
10 changes: 10 additions & 0 deletions deps/libmagic/ChangeLog
@@ -1,3 +1,13 @@
2013-03-06 21:24 Christos Zoulas <christos@zoulas.com>

* fix recursive magic separator printing

2013-02-26 19:28 Christos Zoulas <christos@zoulas.com>

* limit recursion level for mget
* fix pread() related breakage in cdf
* handle offsets properly in recursive "use"

2013-02-18 10:39 Christos Zoulas <christos@zoulas.com>

* add elf reading of debug info to determine if file is stripped
Expand Down
5 changes: 4 additions & 1 deletion deps/libmagic/src/apprentice.c
Expand Up @@ -32,7 +32,7 @@
#include "file.h"

#ifndef lint
FILE_RCSID("@(#)$File: apprentice.c,v 1.189 2013/01/11 16:45:23 christos Exp $")
FILE_RCSID("@(#)$File: apprentice.c,v 1.190 2013/02/17 22:29:40 christos Exp $")
#endif /* lint */

#include "magic.h"
Expand Down Expand Up @@ -2080,6 +2080,7 @@ check_format_type(const char *ptr, int type)
case 'i':
case 'd':
case 'u':
case 'o':
case 'x':
case 'X':
return 0;
Expand All @@ -2094,6 +2095,7 @@ check_format_type(const char *ptr, int type)
case 'i':
case 'd':
case 'u':
case 'o':
case 'x':
case 'X':
return 0;
Expand All @@ -2110,6 +2112,7 @@ check_format_type(const char *ptr, int type)
case 'c':
case 'd':
case 'u':
case 'o':
case 'x':
case 'X':
return 0;
Expand Down
4 changes: 1 addition & 3 deletions deps/libmagic/src/cdf.c
Expand Up @@ -35,7 +35,7 @@
#include "file.h"

#ifndef lint
FILE_RCSID("@(#)$File: cdf.c,v 1.51 2012/03/20 18:28:02 christos Exp $")
FILE_RCSID("@(#)$File: cdf.c,v 1.52 2013/02/18 15:40:59 christos Exp $")
#endif

#include <assert.h>
Expand Down Expand Up @@ -296,8 +296,6 @@ cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
if (info->i_fd == -1)
return -1;

return -1;

if (pread(info->i_fd, buf, len, off) != (ssize_t)len)
return -1;

Expand Down
10 changes: 7 additions & 3 deletions deps/libmagic/src/fsmagic.c
Expand Up @@ -32,7 +32,7 @@
#include "file.h"

#ifndef lint
FILE_RCSID("@(#)$File: fsmagic.c,v 1.65 2012/08/26 09:56:26 christos Exp $")
FILE_RCSID("@(#)$File: fsmagic.c,v 1.66 2013/01/11 19:46:55 christos Exp $")
#endif /* lint */

#include "magic.h"
Expand Down Expand Up @@ -169,8 +169,10 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
* like ordinary files. Otherwise, just report that they
* are block special files and go on to the next file.
*/
if ((ms->flags & MAGIC_DEVICES) != 0)
if ((ms->flags & MAGIC_DEVICES) != 0) {
ret = 0;
break;
}
if (mime) {
if (handle_mime(ms, mime, "chardevice") == -1)
return -1;
Expand Down Expand Up @@ -201,8 +203,10 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
* like ordinary files. Otherwise, just report that they
* are block special files and go on to the next file.
*/
if ((ms->flags & MAGIC_DEVICES) != 0)
if ((ms->flags & MAGIC_DEVICES) != 0) {
ret = 0;
break;
}
if (mime) {
if (handle_mime(ms, mime, "blockdevice") == -1)
return -1;
Expand Down
22 changes: 11 additions & 11 deletions deps/libmagic/src/print.c
Expand Up @@ -32,7 +32,7 @@
#include "file.h"

#ifndef lint
FILE_RCSID("@(#)$File: print.c,v 1.74 2012/05/15 17:14:36 christos Exp $")
FILE_RCSID("@(#)$File: print.c,v 1.75 2012/10/30 23:11:51 christos Exp $")
#endif /* lint */

#include <string.h>
Expand All @@ -59,20 +59,19 @@ file_mdump(struct magic *m)

if (m->flag & INDIR) {
(void) fprintf(stderr, "(%s,",
/* Note: type is unsigned */
(m->in_type < file_nnames) ?
file_names[m->in_type] : "*bad*");
/* Note: type is unsigned */
(m->in_type < file_nnames) ? file_names[m->in_type] :
"*bad in_type*");
if (m->in_op & FILE_OPINVERSE)
(void) fputc('~', stderr);
(void) fprintf(stderr, "%c%u),",
((size_t)(m->in_op & FILE_OPS_MASK) <
SZOF(optyp)) ?
optyp[m->in_op & FILE_OPS_MASK] : '?',
m->in_offset);
((size_t)(m->in_op & FILE_OPS_MASK) <
SZOF(optyp)) ? optyp[m->in_op & FILE_OPS_MASK] : '?',
m->in_offset);
}
(void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "",
/* Note: type is unsigned */
(m->type < file_nnames) ? file_names[m->type] : "*bad*");
/* Note: type is unsigned */
(m->type < file_nnames) ? file_names[m->type] : "*bad type");
if (m->mask_op & FILE_OPINVERSE)
(void) fputc('~', stderr);

Expand Down Expand Up @@ -135,6 +134,7 @@ file_mdump(struct magic *m)
case FILE_MELONG:
case FILE_BESHORT:
case FILE_BELONG:
case FILE_INDIRECT:
(void) fprintf(stderr, "%d", m->value.l);
break;
case FILE_BEQUAD:
Expand Down Expand Up @@ -200,7 +200,7 @@ file_mdump(struct magic *m)
(void) fprintf(stderr, "'%s'", m->value.s);
break;
default:
(void) fputs("*bad*", stderr);
(void) fprintf(stderr, "*bad type %d*", m->type);
break;
}
}
Expand Down
16 changes: 2 additions & 14 deletions deps/libmagic/src/readelf.c
Expand Up @@ -27,7 +27,7 @@
#include "file.h"

#ifndef lint
FILE_RCSID("@(#)$File: readelf.c,v 1.95 2013/02/18 15:40:59 christos Exp $")
FILE_RCSID("@(#)$File: readelf.c,v 1.96 2013/02/22 01:35:49 christos Exp $")
#endif

#ifdef BUILTIN_ELF
Expand Down Expand Up @@ -58,9 +58,7 @@ private size_t donote(struct magic_set *, void *, size_t, size_t, int,

private uint16_t getu16(int, uint16_t);
private uint32_t getu32(int, uint32_t);
#ifndef USE_ARRAY_FOR_64BIT_TYPES
private uint64_t getu64(int, uint64_t);
#endif

private uint16_t
getu16(int swap, uint16_t value)
Expand Down Expand Up @@ -102,7 +100,6 @@ getu32(int swap, uint32_t value)
return value;
}

#ifndef USE_ARRAY_FOR_64BIT_TYPES
private uint64_t
getu64(int swap, uint64_t value)
{
Expand All @@ -127,19 +124,10 @@ getu64(int swap, uint64_t value)
} else
return value;
}
#endif

#define elf_getu16(swap, value) getu16(swap, value)
#define elf_getu32(swap, value) getu32(swap, value)
#ifdef USE_ARRAY_FOR_64BIT_TYPES
# define elf_getu64(swap, array) \
((swap ? ((uint64_t)elf_getu32(swap, array[0])) << 32 \
: elf_getu32(swap, array[0])) + \
(swap ? elf_getu32(swap, array[1]) : \
((uint64_t)elf_getu32(swap, array[1]) << 32)))
#else
# define elf_getu64(swap, value) getu64(swap, value)
#endif
#define elf_getu64(swap, value) getu64(swap, value)

#define xsh_addr (clazz == ELFCLASS32 \
? (void *)&sh32 \
Expand Down
8 changes: 0 additions & 8 deletions deps/libmagic/src/readelf.h
Expand Up @@ -44,17 +44,9 @@ typedef uint16_t Elf32_Half;
typedef uint32_t Elf32_Word;
typedef uint8_t Elf32_Char;

#if SIZEOF_LONG_LONG != 8
#define USE_ARRAY_FOR_64BIT_TYPES
typedef uint32_t Elf64_Addr[2];
typedef uint32_t Elf64_Off[2];
typedef uint32_t Elf64_Xword[2];
#else
#undef USE_ARRAY_FOR_64BIT_TYPES
typedef uint64_t Elf64_Addr;
typedef uint64_t Elf64_Off;
typedef uint64_t Elf64_Xword;
#endif
typedef uint16_t Elf64_Half;
typedef uint32_t Elf64_Word;
typedef uint8_t Elf64_Char;
Expand Down

0 comments on commit bf172ac

Please sign in to comment.