From: Christos Zoulas Date: Sun, 7 Mar 2004 16:16:14 +0000 (+0000) Subject: check for file too small before dereferencing a pointer X-Git-Tag: FILE5_05~899 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0ba3486d1ec06f27535e7836d98ba4adbf05227;p=file check for file too small before dereferencing a pointer --- diff --git a/src/apprentice.c b/src/apprentice.c index 6cf51d88..33ce218f 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -50,7 +50,7 @@ #endif #ifndef lint -FILE_RCSID("@(#)$Id: apprentice.c,v 1.72 2003/12/23 17:33:38 christos Exp $") +FILE_RCSID("@(#)$Id: apprentice.c,v 1.73 2004/03/07 16:16:14 christos Exp $") #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -971,6 +971,10 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, file_error(ms, errno, "cannot stat `%s'", dbname); goto error; } + if (st.st_size < 16) { + file_error(ms, 0, "file `%s' is too small", dbname); + goto error; + } #ifdef QUICK if ((mm = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,