🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.usg
Article #24

Bug in System V tar (simple fix included)

#24
From: laman
Date: Fri, 18 Nov 1983 17:40
46 lines
2010 bytes
There is a bug in the System V "tar" source distribution.  If the user
creates a tape with a blocking factor of one (1) 512 bytes block per record,
tar gets stuck in an infinite loop when the user executes the following:

% tar tvf /dev/rmt0

or

% tar tvbf 1 /dev/rmt0

but the following work:

% tar tvfb /dev/rmt0 1

or

% tar tv0

(Tar also gets lost when extractions are attempted in the same manor.)

The problem is that in the 'f' case in the argument processing, "tar" can't
tell the difference between "nblock"'s initial value, and a value
specified with the 'b' option.  When a blocking factor of one (1) is specified,
it looks just like the initial value given to "nblock", so when "nblock"'s
value is zeroed (when it was one (1)) in the 'f' case , the user's
specified value is lost.  If the program is extracting, garbage is put into
the file.

The fix is to declare a "bflag" variable (initially set to zero), set it to one
when the 'b' option is processed, and modify the "if" statement comparing
"nblock" to one in the code that processes the 'f' option to require "bflag"
to be off (If it's on, then we know we have gotten the blocking factor).

39c39
< int	rflag, xflag, vflag, tflag, mt, cflag, mflag, bflag;
---
> int	rflag, xflag, vflag, tflag, mt, cflag, mflag;
74c74
< 			if (nblock == 1 && !bflag)
---
> 			if (nblock == 1)
126d125
< 			bflag = 1;

			Mike Laman
			UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman
Technical Details
Message-ID: <24@sdcsvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!laman

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site sdcsvax.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!laman
From: laman@sdcsvax.UUCP
Newsgroups: net.bugs.usg,net.bugs
Subject: Bug in System V tar (simple fix included)
Message-ID: <24@sdcsvax.UUCP>
Date: Fri, 18-Nov-83 12:40:13 EST
Article-I.D.: sdcsvax.24
Posted: Fri Nov 18 12:40:13 1983
Date-Received: Sun, 20-Nov-83 07:11:18 EST
Organization: U.C. San Diego, Computer Science Dept.
Lines: 46