From: Christos Zoulas <christos@zoulas.com>
Date: Fri, 27 Oct 2006 14:51:27 +0000 (+0000)
Subject: fix possible unterminated string.
X-Git-Tag: FILE4_18~8
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92e58cd28759ff2132a78d37a058ca0c4b0cc018;p=file

fix possible unterminated string.
---

diff --git a/ChangeLog b/ChangeLog
index 5e01e98e..92042d11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+	* make sure that we nul terminate desc (Ryoji Kanai)
+
 	* don't process elf notes multiple times
 
 	* allow -z to report empty compressed files
diff --git a/src/apprentice.c b/src/apprentice.c
index b32c1f87..375f23b3 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -46,7 +46,7 @@
 #endif
 
 #ifndef	lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.95 2006/06/08 22:48:51 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.96 2006/10/27 14:51:28 christos Exp $")
 #endif	/* lint */
 
 #define	EATAB {while (isascii((unsigned char) *l) && \
@@ -835,8 +835,9 @@ GetDesc:
 		m->nospflag = 1;
 	} else
 		m->nospflag = 0;
-	for (i = 0; (m->desc[i++] = *l++) != '\0' && i < MAXDESC; )
+	for (i = 0; (m->desc[i++] = *l++) != '\0' && i < sizeof(m->desc); )
 		continue;
+	m->desc[sizeof(m->desc) - 1] = '\0';
 
         /*
 	 * We only do this check while compiling, or if any of the magic