From 7f99e8c3bd1b32a870b8480f0c3ad115ed7db07a Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Thu, 2 Mar 2006 22:08:22 +0000 Subject: [PATCH] Stop early if the string is not long enough. --- src/ascmagic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- 2.40.0