#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.229 2015/01/01 17:07:34 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.230 2015/01/02 21:29:39 christos Exp $")
#endif /* lint */
#include "magic.h"
size_t i;
const char *l = line;
struct magic *m = &me->mp[me->cont_count == 0 ? 0 : me->cont_count - 1];
- char *buf = (char *)m + off;
+ char *buf = CAST(char *, CAST(void *, m)) + off;
if (buf[0] != '\0') {
len = nt ? strlen(buf) : len;
{
struct magic *m = &me->mp[0];
- return parse_extra(ms, me, line, offsetof(struct magic, apple),
+ return parse_extra(ms, me, line,
+ CAST(off_t, offsetof(struct magic, apple)),
sizeof(m->apple), "APPLE", "!+-./", 0);
}
{
struct magic *m = &me->mp[0];
- return parse_extra(ms, me, line, offsetof(struct magic, mimetype),
+ return parse_extra(ms, me, line,
+ CAST(off_t, offsetof(struct magic, mimetype)),
sizeof(m->mimetype), "MIME", "+-/.", 1);
}
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.69 2014/12/04 15:56:46 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.70 2015/01/02 21:29:39 christos Exp $")
#endif
#include <assert.h>
#define CDF_TOLE8(x) ((uint64_t)(NEED_SWAP ? _cdf_tole8(x) : (uint64_t)(x)))
#define CDF_TOLE4(x) ((uint32_t)(NEED_SWAP ? _cdf_tole4(x) : (uint32_t)(x)))
#define CDF_TOLE2(x) ((uint16_t)(NEED_SWAP ? _cdf_tole2(x) : (uint16_t)(x)))
-#define CDF_TOLE(x) (sizeof(x) == 2 ? CDF_TOLE2(x) : (sizeof(x) == 4 ? \
- CDF_TOLE4(x) : CDF_TOLE8(x)))
+#define CDF_TOLE(x) (/*CONSTCOND*/sizeof(x) == 2 ? \
+ CDF_TOLE2(CAST(uint16_t, x)) : \
+ (/*CONSTCOND*/sizeof(x) == 4 ? \
+ CDF_TOLE4(CAST(uint32_t, x)) : \
+ CDF_TOLE8(CAST(uint64_t, x))))
#define CDF_GETUINT32(x, y) cdf_getuint32(x, y)
const char *e = ((const char *)p) + tail;
size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
- (void)&line;
+ /*LINTED*/(void)&line;
if (e >= b && (size_t)(e - b) <= ss * sst->sst_len)
return 0;
DPRINTF(("%d: offset begin %p < end %p || %" SIZE_T_FORMAT "u"
}
-#define extract_catalog_field(f, l) \
+#define extract_catalog_field(t, f, l) \
memcpy(&ce[i].f, b + (l), sizeof(ce[i].f)); \
- ce[i].f = CDF_TOLE(ce[i].f)
+ ce[i].f = CAST(t, CDF_TOLE(ce[i].f))
int
cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst,
ce = (*cat)->cat_e;
b = CAST(const char *, sst->sst_tab);
for (i = 0; i < nr; i++) {
- extract_catalog_field(ce_namlen, 0);
- extract_catalog_field(ce_num, 2);
- extract_catalog_field(ce_timestamp, 6);
+ extract_catalog_field(uint16_t, ce_namlen, 0);
+ extract_catalog_field(uint16_t, ce_num, 2);
+ extract_catalog_field(uint64_t, ce_timestamp, 6);
reclen = ce[i].ce_namlen;
ce[i].ce_namlen =
sizeof(ce[i].ce_name) / sizeof(ce[i].ce_name[0]) - 1;
if (ce[i].ce_namlen > reclen - 14)
ce[i].ce_namlen = reclen - 14;
- np = CAST(const uint16_t *, (b + 16));
+ np = CAST(const uint16_t *, CAST(const void *, (b + 16)));
for (k = 0; k < ce[i].ce_namlen; k++) {
- ce[i].ce_name[k] = np[k];
- CDF_TOLE2(ce[i].ce_name[k]);
+ ce[i].ce_name[k] = np[k]; /* XXX: CDF_TOLE2? */
}
ce[i].ce_name[ce[i].ce_namlen] = 0;
b += reclen;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.77 2014/12/12 16:33:01 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.78 2015/01/02 21:29:39 christos Exp $")
#endif
#include "magic.h"
int fdin[2], fdout[2];
int status;
ssize_t r;
- pid_t pid;
#ifdef BUILTIN_DECOMPRESS
/* FIXME: This doesn't cope with bzip2 */
file_error(ms, errno, "cannot create pipe");
return NODATA;
}
- switch (pid = fork()) {
+ switch (fork()) {
case 0: /* child */
(void) close(0);
if (fd != -1) {
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: file.c,v 1.160 2014/12/16 23:18:40 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.161 2015/01/02 21:29:39 christos Exp $")
#endif /* lint */
#include "magic.h"
private char *progname; /* used throughout */
+#ifdef __dead
+__dead
+#endif
private void usage(void);
private void docprint(const char *);
+#ifdef __dead
+__dead
+#endif
private void help(void);
private int unwrap(struct magic_set *, const char *);
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.164 2015/01/01 17:07:34 christos Exp $
+ * @(#)$File: file.h,v 1.165 2015/01/02 21:29:39 christos Exp $
*/
#ifndef __file_h__
#else
#define FILE_RCSID(id)
#endif
+#ifndef __RCSID
+#define __RCSID(a)
+#endif
#endif /* __file_h__ */
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.79 2014/12/16 20:52:49 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.80 2015/01/02 21:29:39 christos Exp $")
#endif /* lint */
#include "magic.h"
}
#ifndef COMPILE_ONLY
+/*ARGSUSED*/
protected int
-file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unused)),
+file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__unused__)),
const void *buf, size_t nb)
{
int m = 0, rv = 0, looks_text = 0;
if (ptr >= eptr - 3)
break;
*ptr++ = '\\';
- *ptr++ = ((*s >> 6) & 7) + '0';
- *ptr++ = ((*s >> 3) & 7) + '0';
- *ptr++ = ((*s >> 0) & 7) + '0';
+ *ptr++ = ((CAST(unsigned int, *s) >> 6) & 7) + '0';
+ *ptr++ = ((CAST(unsigned int, *s) >> 3) & 7) + '0';
+ *ptr++ = ((CAST(unsigned int, *s) >> 0) & 7) + '0';
}
*ptr = '\0';
return buf;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: magic.c,v 1.91 2014/12/16 23:18:40 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.92 2015/01/02 21:29:39 christos Exp $")
#endif /* lint */
#include "magic.h"
{
switch (param) {
case MAGIC_PARAM_INDIR_MAX:
- ms->indir_max = *(const size_t *)val;
+ ms->indir_max = (uint16_t)*(const size_t *)val;
return 0;
case MAGIC_PARAM_NAME_MAX:
- ms->name_max = *(const size_t *)val;
+ ms->name_max = (uint16_t)*(const size_t *)val;
return 0;
case MAGIC_PARAM_ELF_PHNUM_MAX:
- ms->elf_phnum_max = *(const size_t *)val;
+ ms->elf_phnum_max = (uint16_t)*(const size_t *)val;
return 0;
case MAGIC_PARAM_ELF_SHNUM_MAX:
- ms->elf_shnum_max = *(const size_t *)val;
+ ms->elf_shnum_max = (uint16_t)*(const size_t *)val;
return 0;
case MAGIC_PARAM_ELF_NOTES_MAX:
- ms->elf_notes_max = *(const size_t *)val;
+ ms->elf_notes_max = (uint16_t)*(const size_t *)val;
return 0;
default:
errno = EINVAL;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: print.c,v 1.76 2013/02/26 18:25:00 christos Exp $")
+FILE_RCSID("@(#)$File: print.c,v 1.77 2015/01/02 21:29:39 christos Exp $")
#endif /* lint */
#include <string.h>
case FILE_MELDATE:
(void)fprintf(stderr, "%s,",
file_fmttime(m->value.l, 0, tbuf));
+ break;
case FILE_QDATE:
case FILE_LEQDATE:
case FILE_BEQDATE:
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.49 2014/12/04 15:56:46 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.50 2015/01/02 21:29:39 christos Exp $")
#endif
#include <assert.h>
#include "cdf.h"
#include "magic.h"
+#ifndef __arraycount
+#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
+#endif
+
#define NOTMIME(ms) (((ms)->flags & MAGIC_MIME) == 0)
static const struct nv {
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.117 2014/12/16 23:29:42 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.118 2015/01/02 21:29:39 christos Exp $")
#endif
#ifdef BUILTIN_ELF
}
private int
+/*ARGSUSED*/
do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
int swap __attribute__((__unused__)), uint32_t namesz, uint32_t descsz,
size_t noff, size_t doff, int *flags)
return 1;
for (i = 0; i < __arraycount(pax); i++) {
- if (((1 << i) & desc) == 0)
+ if (((1 << (int)i) & desc) == 0)
continue;
if (file_printf(ms, "%s%s", did++ ? "," : "",
pax[i]) == -1)
}
/* Read offset of name section to be able to read section names later */
- if (pread(fd, xsh_addr, xsh_sizeof, off + size * strtab) < (ssize_t)xsh_sizeof) {
+ if (pread(fd, xsh_addr, xsh_sizeof, CAST(off_t, (off + size * strtab)))
+ < (ssize_t)xsh_sizeof) {
file_badread(ms);
return -1;
}
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.206 2015/01/01 17:07:34 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.207 2015/01/02 21:29:39 christos Exp $")
#endif /* lint */
#include "magic.h"
case FILE_INDIRECT:
if (m->str_flags & INDIRECT_RELATIVE)
- offset += o;
+ offset += CAST(uint32_t, o);
if (offset == 0)
return 0;