From: Christos Zoulas Date: Thu, 2 Mar 2006 22:08:22 +0000 (+0000) Subject: Stop early if the string is not long enough. X-Git-Tag: FILE5_05~766 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=444e815688725f1e660d19fd1a65f26e5916b9a1;p=file Stop early if the string is not long enough. --- diff --git a/src/ascmagic.c b/src/ascmagic.c index 4fced4be..130b1722 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.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