From 7db05be097841d497de430adc39349ba3989a6e9 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Thu, 16 Sep 1993 21:09:35 +0000 Subject: [PATCH] Is_tar now takes the length in bytes of the buffer to be tested. --- src/is_tar.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/is_tar.c b/src/is_tar.c index 789f04e5..5b036be1 100644 --- a/src/is_tar.c +++ b/src/is_tar.c @@ -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; -- 2.40.0