diff options
author | Christos Zoulas <christos@zoulas.com> | 2006-03-12 22:09:33 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2006-03-12 22:09:33 +0000 |
commit | d3297090d51a55be277e6aeb35cffbb08f39d21a (patch) | |
tree | c0c3ba1ceba1833b11d259dfe4e5769bf75d7e0c /src | |
parent | 4cd764229bfbe690fad07a87321c0b254cc77dc6 (diff) | |
download | file-git-d3297090d51a55be277e6aeb35cffbb08f39d21a.tar.gz |
Report empty when null/0 is passed in magic_buffer. (Mike Frysinger)
Diffstat (limited to 'src')
-rw-r--r-- | src/ascmagic.c | 6 | ||||
-rw-r--r-- | src/softmagic.c | 7 |
2 files changed, 10 insertions, 3 deletions
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; |