]> granicus.if.org Git - file/commitdiff
Is_tar now takes the length in bytes of the buffer to be
authorChristos Zoulas <christos@zoulas.com>
Thu, 16 Sep 1993 21:09:35 +0000 (21:09 +0000)
committerChristos Zoulas <christos@zoulas.com>
Thu, 16 Sep 1993 21:09:35 +0000 (21:09 +0000)
tested.

src/is_tar.c

index 789f04e5027ec12d90e1e3545a58fd9437db81cb..5b036be1af8d088545737143acd01f04dbc7fd8c 100644 (file)
@@ -5,7 +5,7 @@
  * Pubic Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
  *
  * @(#)list.c 1.18 9/23/86 Public Domain - gnu
- * $Id: is_tar.c,v 1.7 1992/09/08 15:32:19 ian Exp $
+ * $Id: is_tar.c,v 1.8 1993/09/16 21:09:35 christos Exp $
  *
  * Comments changed and some code/comments reformatted
  * for file command by Ian Darwin.
@@ -31,14 +31,18 @@ static long from_oct();
  *     2 for Unix Std (POSIX) tar file.
  */
 int
-is_tar(buf)
+is_tar(buf, nbytes)
 unsigned char *buf;
+int nbytes;
 {
        register union record *header = (union record *)buf;
        register int    i;
        register long   sum, recsum;
        register char   *p;
 
+       if (nbytes < sizeof(union record))
+               return 0;
+
        recsum = from_oct(8,  header->header.chksum);
 
        sum = 0;