Skip to main content.
home | support | download

Back to List Archive

SWISH-E Bug: Infinite Loop in uncompress1() on error

From: Patrick O'Lone <polone(at)not-real.townnews.com>
Date: Fri Dec 10 2004 - 22:15:01 GMT
Hello all,

We use Swish-E over NFS and occasionally we get corrupt indexes. As a 
result, we've witnessed an error that can occur when the zlib compress 
fails AND you use -L option. Basically, in the uncompress1() function in 
compress.c, an infinite loop occurs because f_getc() is failing and not 
being handled. The fix is as follows:

/* Uncompress a number from a file */
int     uncompress1(FILE * fp, int (*f_getc) (FILE *))
{
     int     _c;
     int     num = 0;

     do
     {
         _c = (int) f_getc(fp);
	/* BEGIN FIX */
         if (_c < 0) {
             break;
         }
	/* END FIX */
         num <<= 7;
         num |= _c & 127;
         if (!num)
             break;
     }
     while (_c & 128);

     return num;
}

Regards,

-- 
Patrick O'Lone
Software Project Manager
TownNews.com

E-mail ... polone@townnews.com
Phone .... 309-743-0809
Fax ...... 309-743-0830
Received on Fri Dec 10 14:15:11 2004