From: Christos Zoulas Date: Sun, 12 Mar 2006 22:09:33 +0000 (+0000) Subject: Report empty when null/0 is passed in magic_buffer. (Mike Frysinger) X-Git-Tag: FILE5_05~760 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=00e9fa59116f8c8b5daa977d4e6e0fc0b08116f9;p=file Report empty when null/0 is passed in magic_buffer. (Mike Frysinger) --- diff --git a/src/ascmagic.c b/src/ascmagic.c index 130b1722..43d467cd 100644 --- a/src/ascmagic.c +++ b/src/ascmagic.c @@ -49,7 +49,7 @@ #include "names.h" #ifndef lint -FILE_RCSID("@(#)$Id: ascmagic.c,v 1.44 2006/03/02 22:08:22 christos Exp $") +FILE_RCSID("@(#)$Id: ascmagic.c,v 1.45 2006/03/12 22:09:33 christos Exp $") #endif /* lint */ typedef unsigned long unichar; @@ -154,8 +154,10 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes) } } - if (nbytes <= 1) + if (nbytes <= 1) { + rv = 0; goto done; + } /* * for troff, look for . + letter + letter or .\"; diff --git a/src/softmagic.c b/src/softmagic.c index 2e78fdcb..edcba5e5 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -39,7 +39,7 @@ #ifndef lint -FILE_RCSID("@(#)$Id: softmagic.c,v 1.77 2005/10/20 14:59:01 christos Exp $") +FILE_RCSID("@(#)$Id: softmagic.c,v 1.78 2006/03/12 22:09:33 christos Exp $") #endif /* lint */ private int match(struct magic_set *, struct magic *, uint32_t, @@ -664,6 +664,11 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, * (starting at 1), not as bytes-from start-of-file */ char *b, *c, *last = NULL; + if (s == NULL) { + p->search.buflen = 0; + p->search.buf = NULL; + return 0; + } if ((p->search.buf = strdup((const char *)s)) == NULL) { file_oomem(ms); return -1;