]> granicus.if.org Git - file/commitdiff
Stop early if the string is not long enough.
authorChristos Zoulas <christos@zoulas.com>
Thu, 2 Mar 2006 22:08:22 +0000 (22:08 +0000)
committerChristos Zoulas <christos@zoulas.com>
Thu, 2 Mar 2006 22:08:22 +0000 (22:08 +0000)
src/ascmagic.c

index 4fced4be9e7815234fc88933187efe3b99601626..130b1722800d47c8b81f1c97a763272e8a4171aa 100644 (file)
@@ -49,7 +49,7 @@
 #include "names.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: ascmagic.c,v 1.43 2005/06/25 15:52:14 christos Exp $")
+FILE_RCSID("@(#)$Id: ascmagic.c,v 1.44 2006/03/02 22:08:22 christos Exp $")
 #endif /* lint */
 
 typedef unsigned long unichar;
@@ -154,6 +154,9 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
                }
        }
 
+       if (nbytes <= 1)
+               goto done;
+
        /*
         * for troff, look for . + letter + letter or .\";
         * this must be done to disambiguate tar archives' ./file