[comp.sources.d] Another bug in unix lharc corrected

matthieu@laas.fr (Matthieu Herrb) (03/28/90)

I found another little bug in the unix version of lharc: it dumped
core when extracting files with length zero. 

It is a division by zero in lzhuf.c. Here is the patch:

*** lzhuf.c~	Sun Mar 18 14:59:06 1990
--- lzhuf.c	Wed Mar 28 10:27:48 1990
***************
*** 882,888 ****
  		((size  + (m * INDICATOR_THRESHOLD - 1)) /
  		 (m * INDICATOR_THRESHOLD) *
  		 INDICATOR_THRESHOLD);
! 	i = ((size + (indicator_threshold - 1)) / indicator_threshold);
  	while (i--)
  		putchar (DOT);
  	indicator_count = 0;
--- 882,891 ----
  		((size  + (m * INDICATOR_THRESHOLD - 1)) /
  		 (m * INDICATOR_THRESHOLD) *
  		 INDICATOR_THRESHOLD);
! 	if (indicator_threshold != 0)
! 		i = ((size + (indicator_threshold - 1)) / indicator_threshold);
! 	else
! 		i = 0;
  	while (i--)
  		putchar (DOT);
  	indicator_count = 0;

Hope this helps.

PS: I found better compression rate with lharc than whin tar and
compress which was the best.

					Matthieu Herrb

--
\  /  | Matthieu Herrb             CNRS - LAAS 
|\/|--| matthieu@idefix.laas.fr    7, avenue du Colonel Roche
|  |  |                            31077 Toulouse Cedex - France
"If You're not Part of the Solution, You're Part of the Problem..."