NetBSD Problem Report #867
From gnats Sun Mar 12 19:11:43 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with ESMTP id TAA00986 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Sun, 12 Mar 1995 19:11:42 -0800
Message-Id: <199503130051.QAA16934@mindslayer.mother.com>
Date: Sun, 12 Mar 1995 16:51:55 -0800
From: cml@mindslayer.mother.com
Reply-To: cml@mindslayer.mother.com
To: gnats-bugs@netbsd.org
Subject: /usr/bin/file breaks on tar's of . files.
X-Send-Pr-Version: 3.2
>Number: 867
>Category: bin
>Synopsis: /usr/bin/file breaks on tar's of . files.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 12 19:20:03 +0000 1995
>Closed-Date: Sun May 28 20:20:47 +0000 1995
>Last-Modified:
>Originator: Chris Lambertus
>Release: 1.0 and -current
>Organization:
" None"
>Environment:
System: NetBSD mindslayer 1.0 NetBSD 1.0 (MINDSLAYER) #0: Sun Feb 5 02:35:23 PST 1995 root@mindslayer:/usr/src/sys/arch/i386/compile/MINDSLAYER i386
>Description:
/usr/bin/file incorrectly reports tar archives when the first
file in the archive starts with . The . is cased as a troff
document in ascmagic.c before the is_tar routine runs.
>How-To-Repeat:
tar -cf foo.tar .profile
file foo.tar
foo.tar: troff or preprocessor input text
>Fix:
Apply this patch which reorders the checks in ascmagic.c:
*** /usr/src/usr.bin/file/ascmagic.orig Fri Apr 8 03:16:38 1994
--- /usr/src/usr.bin/file/ascmagic.c Sun Mar 12 16:16:54 1995
***************
*** 52,58 ****
char *token;
register struct names *p;
! /* these are easy, do them first */
/*
* for troff, look for . + letter + letter or .\";
--- 52,88 ----
char *token;
register struct names *p;
!
! switch (is_tar(buf)) {
! case 1:
! ckfputs("tar archive", stdout);
! return 1;
! case 2:
! ckfputs("POSIX tar archive", stdout);
! return 1;
! }
!
! if (i = is_compress(buf, &isblock)) {
! if (zflag) {
! unsigned char *newbuf;
! int newsize;
!
! if (newsize = uncompress(buf, &newbuf, nbytes)) {
! tryit(newbuf, newsize);
! free(newbuf);
! }
! printf(" (%scompressed data - %d bits)",
! isblock ? "block " : "", i);
! }
! else printf("%scompressed data - %d bits",
! isblock ? "block " : "", i);
! return 1;
! }
!
! for (i = 0; i < nbytes; i++) {
! if (!isascii(*(buf+i)))
! return 0; /* not all ascii */
! }
/*
* for troff, look for . + letter + letter or .\";
***************
*** 70,75 ****
--- 100,106 ----
return 1;
}
}
+
if ((*buf == 'c' || *buf == 'C') &&
isascii(*(buf + 1)) && isspace(*(buf + 1))) {
ckfputs("fortran program text", stdout);
***************
*** 92,128 ****
return 1;
}
}
- }
-
- switch (is_tar(buf)) {
- case 1:
- ckfputs("tar archive", stdout);
- return 1;
- case 2:
- ckfputs("POSIX tar archive", stdout);
- return 1;
- }
-
- if (i = is_compress(buf, &isblock)) {
- if (zflag) {
- unsigned char *newbuf;
- int newsize;
-
- if (newsize = uncompress(buf, &newbuf, nbytes)) {
- tryit(newbuf, newsize);
- free(newbuf);
- }
- printf(" (%scompressed data - %d bits)",
- isblock ? "block " : "", i);
- }
- else printf("%scompressed data - %d bits",
- isblock ? "block " : "", i);
- return 1;
- }
-
- for (i = 0; i < nbytes; i++) {
- if (!isascii(*(buf+i)))
- return 0; /* not all ascii */
}
/* all else fails, but it is ascii... */
--- 123,128 ----
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: christos
State-Changed-When: Sun May 28 16:20:47 EDT 1995
State-Changed-Why:
Fixed the bug
.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.