]> granicus.if.org Git - file/commitdiff
Report empty when null/0 is passed in magic_buffer. (Mike Frysinger)
authorChristos Zoulas <christos@zoulas.com>
Sun, 12 Mar 2006 22:09:33 +0000 (22:09 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sun, 12 Mar 2006 22:09:33 +0000 (22:09 +0000)
src/ascmagic.c
src/softmagic.c

index 130b1722800d47c8b81f1c97a763272e8a4171aa..43d467cd3e2297dd4d1bddda8bb2626ade3cfbd0 100644 (file)
@@ -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 .\";
index 2e78fdcbef1510a3c534ee6a949b93b8dc0bc395..edcba5e5f80eaa9c5b3ee036039576710b145f1a 100644 (file)
@@ -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;