#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.96 2006/10/27 14:51:28 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.97 2006/10/27 14:57:32 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
};
const int file_formats[] = { FILE_FORMAT_STRING };
-const int file_nformats = sizeof(file_formats) / sizeof(file_formats[0]);
+const size_t file_nformats = sizeof(file_formats) / sizeof(file_formats[0]);
const char *file_names[] = { FILE_FORMAT_NAME };
-const int file_nnames = sizeof(file_names) / sizeof(file_names[0]);
+const size_t file_nnames = sizeof(file_names) / sizeof(file_names[0]);
private int getvalue(struct magic_set *ms, struct magic *, const char **);
private int hextoint(int);
parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
const char *line, int action)
{
- int i;
+ size_t i;
struct magic_entry *me;
struct magic *m;
const char *l = line;
m->nospflag = 0;
for (i = 0; (m->desc[i++] = *l++) != '\0' && i < sizeof(m->desc); )
continue;
- m->desc[sizeof(m->desc) - 1] = '\0';
+ if (i == sizeof(m->desc)) {
+ m->desc[sizeof(m->desc) - 1] = '\0';
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "description `%s' truncated", m->desc);
+ }
/*
* We only do this check while compiling, or if any of the magic
*/
/*
* file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.76 2006/06/08 22:48:51 christos Exp $
+ * @(#)$Id: file.h,v 1.77 2006/10/27 14:57:32 christos Exp $
*/
#ifndef __file_h__
protected const char *file_getbuffer(struct magic_set *);
protected ssize_t sread(int, void *, size_t);
+#ifndef COMPILE_ONLY
+extern const char *file_names[];
+extern const size_t file_nnames;
+#endif
+
#ifndef HAVE_STRERROR
extern int sys_nerr;
extern char *sys_errlist[];
static const char *rcsid(const char *p) { \
return rcsid(p = id); \
}
-#else
#endif /* __file_h__ */
#include <time.h>
#ifndef lint
-FILE_RCSID("@(#)$Id: print.c,v 1.52 2006/06/08 22:48:51 christos Exp $")
+FILE_RCSID("@(#)$Id: print.c,v 1.53 2006/10/27 14:57:32 christos Exp $")
#endif /* lint */
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
file_mdump(struct magic *m)
{
private const char optyp[] = { FILE_OPS };
- extern const char *file_names[];
- extern const int file_nnames;
(void) fputc('[', stderr);
(void) fprintf(stderr, ">>>>>>>> %d" + 8 - (m->cont_level & 7),