Article View: net.bugs.usg
Article #284Bug in cpio with multiple `reels', FIX
From: Bruce Robertson
Date: Wed, 26 Mar 1986 06:15
Date: Wed, 26 Mar 1986 06:15
41 lines
1893 bytes
1893 bytes
Description:
There is a bug in cpio that causes it to do strange things, usually
either a core dump or an infinite loop, when you reach the 17th
`reel' of a multiple reel cpio file, such as with floppies.
Repeat-By:
Just do a directory listing, cpio -itvB, of a cpio file occupying
more than 17 `reels'.
Fix:
The problem is that cpio opens /dev/tty to prompt the user for
a new input file name, and never bothers to close it. Also, it
never checks to see if the open succeeded, resulting in a call
to fgets() with a null FILE pointer. This is what causes the
infinite loop and/or core dump. Here's the fix:
*** /usr/src/cmd/cpio.c-old Tue Mar 25 22:09:48 1986
--- /usr/src/cmd/cpio.c Tue Mar 25 22:09:53 1986
***************
*** 1173,1178
fprintf(stderr,"If you want to go on, type device/file name when ready\n");
devtty = fopen("/dev/tty", "r");
fgets(str, 20, devtty);
str[strlen(str) - 1] = '\0';
if(!*str)
exit(2);
--- 1176,1182 -----
fprintf(stderr,"If you want to go on, type device/file name when ready\n");
devtty = fopen("/dev/tty", "r");
fgets(str, 20, devtty);
+ fclose(devtty);
str[strlen(str) - 1] = '\0';
if(!*str)
exit(2);
--
Bruce Robertson
UUCP: cbosgd!utah-cs!utah-gr!stride!bruce
ARPA: stride!bruce@utah-gr.arpa
Technical Details
Message-ID:
<565@stride.stride.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!utah-cs!utah-gr!stride!bruceShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!utah-cs!utah-gr!stride!bruce From: bruce@stride.UUCP (Bruce Robertson) Newsgroups: net.bugs.usg Subject: Bug in cpio with multiple `reels', FIX Message-ID: <565@stride.stride.UUCP> Date: Wed, 26-Mar-86 01:15:45 EST Article-I.D.: stride.565 Posted: Wed Mar 26 01:15:45 1986 Date-Received: Sat, 29-Mar-86 01:19:45 EST Reply-To: bruce@stride.UUCP (Bruce Robertson) Organization: Stride Micro, Reno, NV. Lines: 41