[gnu.utils.bug] tar 1.05 bugs

dpb@SUN.COM (Don Bennett 433-3311, 408) (03/26/89)

Running tar-1.05 on a sun-3, Sun-os 3.5 running tar, /etc/rmt on
Sun-os 4.0, but I hope that doesn't matter:

1) Reblocking code doesn't right when writing a compressed tar file
   to a remote tape drive.  When writing the last block, at least to
   the device /dev/rst8, the number of bytes written must be a multiple
   of 512.

   Recreate the problem via:
      tar cvzf poplar:/dev/rst8 ./stuff

 2) When unpacking a compressed tar file from disc, tar decides it has
    reached the end of the archive and closes the pipe while compress
    is still writing some garbage into it. 
    
Included are patches I use to fix these problems.

*** tar-1.05/buffer.c.orig	Thu Mar  2 09:56:32 1989
--- tar-1.05/buffer.c	Thu Mar 23 14:19:00 1989
***************
*** 402,408 ****
  				}
  			} else {
  				for(;;) {
! 					int n;
  					char *ptr;
  		
  					n=blocksize;
--- 402,408 ----
  				}
  			} else {
  				for(;;) {
! 					int n, partialBlock;
  					char *ptr;
  		
  					n=blocksize;
***************
*** 416,426 ****
  					}
  						/* EOF */
  					if(err==0) {
! 						blocksize-=n;
! 						err=rmtwrite(archive,ar_block->charptr,blocksize);
! 						if(err!=(blocksize))
  							writeerror(err);
- 						blocksize+=n;
  						break;
  					}
  					if(n) {
--- 416,426 ----
  					}
  						/* EOF */
  					if(err==0) {
! 						partialBlock=blocksize-n;
! 						partialBlock = (partialBlock+511)&(~0x1ff);
! 						err=rmtwrite(archive,ar_block->charptr,partialBlock);
! 						if(err!=(partialBlock))
  							writeerror(err);
  						break;
  					}
  					if(n) {
***************
*** 1031,1037 ****
  	}
  	if(f_verify)
  		verify_volume();
! 	(void) rmtclose(archive);
  
  #ifndef	MSDOS
  	if (childpid) {
--- 1031,1043 ----
  	}
  	if(f_verify)
  		verify_volume();
! 
! 	if (ar_reading && f_reblock) {
! 	    static char junkbuf[1024];
! 	    while (read(archive, junkbuf, 1024) > 0)
! 		;
! 	} else
! 	    (void) rmtclose(archive);
  
  #ifndef	MSDOS
  	if (childpid) {