+2003-06-10 17:03 Christos Zoulas <christos@zoulas.com>
+
+ * make sure we don't access uninitialized memory.
+ * pass lint
+ * #ifdef __cplusplus in magic.h
+
2003-05-25 19:23 Christos Zoulas <christos@zoulas.com>
* rename cvs magic file to revision to deal with
#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.58 2003/05/23 21:31:58 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.59 2003/06/10 18:28:37 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
const char *);
private size_t maxmagic = 0;
+private size_t magicsize = sizeof(struct magic);
#ifdef COMPILE_ONLY
const char *magicfile;
int rv = -1;
int mapped;
- if (sizeof(*magic) != FILE_MAGICSIZE) {
+ if (magicsize != FILE_MAGICSIZE) {
file_error(ms, "Magic element size %lu != %lu",
(unsigned long)sizeof(*magic),
(unsigned long)FILE_MAGICSIZE);
*
*/
-#ifdef __EMX__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$Id: apptype.c,v 1.3 2003/06/10 18:28:37 christos Exp $")
+#endif /* lint */
+
+#ifdef __EMX__
#include <io.h>
#define INCL_DOSSESMGR
#define INCL_DOSERRORS
#include <os2.h>
typedef ULONG APPTYPE;
-#include "file.h"
-
-#ifndef lint
-FILE_RCSID("@(#)$Id: apptype.c,v 1.2 2003/03/24 14:53:31 christos Exp $")
-#endif /* lint */
-
protected int
file_os2_apptype(struct magic_set *ms, const char *fn, const void *buf,
size_t nb)
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: magic.c,v 1.7 2003/05/23 21:31:58 christos Exp $")
+FILE_RCSID("@(#)$Id: magic.c,v 1.8 2003/06/10 18:28:37 christos Exp $")
#endif /* lint */
#ifdef __EMX__
}
ms->flags = flags;
ms->haderr = 0;
+ ms->mlist = NULL;
return ms;
}
ml = file_apprentice(ms, magicfile, 0);
if (ml == NULL)
return -1;
+ free_mlist(ms->mlist);
ms->mlist = ml;
return 0;
}
#define MAGIC_CONTINUE 0x20 /* Return all matches, not just the first */
#define MAGIC_CHECK 0x40 /* Print warnings to stderr */
-typedef struct magic_set *magic_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct magic_set *magic_t;
magic_t magic_open(int);
void magic_close(magic_t);
int magic_compile(magic_t, const char *);
int magic_check(magic_t, const char *);
+#ifdef __cplusplus
+};
#endif
+
+#endif /* _MAGIC_H */
#ifndef lint
-FILE_RCSID("@(#)$Id: softmagic.c,v 1.59 2003/05/23 21:31:59 christos Exp $")
+FILE_RCSID("@(#)$Id: softmagic.c,v 1.60 2003/06/10 18:28:37 christos Exp $")
#endif /* lint */
private int match(struct magic_set *, struct magic *, uint32_t,
struct magic *, size_t);
private int mcheck(struct magic_set *, union VALUETYPE *, struct magic *);
private int32_t mprint(struct magic_set *, union VALUETYPE *, struct magic *);
-private void mdebug(int32_t, const char *, size_t);
+private void mdebug(uint32_t, const char *, size_t);
private int mconvert(struct magic_set *, union VALUETYPE *, struct magic *);
-private int check_mem(struct magic_set *, int);
+private int check_mem(struct magic_set *, unsigned int);
/*
* softmagic - lookup one file in database
}
private int
-check_mem(struct magic_set *ms, int level)
+check_mem(struct magic_set *ms, unsigned int level)
{
size_t len;
private void
-mdebug(int32_t offset, const char *str, size_t len)
+mdebug(uint32_t offset, const char *str, size_t len)
{
(void) fprintf(stderr, "mget @%d: ", offset);
file_showstr(stderr, str, len);