www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/10/25/08:06:56

From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
To: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU
Date: Wed, 25 Oct 1995 10:57:00 GMT
Subject: Re: An apparent fault in GZIP

  "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk> wrote (Subject: An apparent
fault in GZIP):-

> ... Here follows a program that I just wrote that successfully unzips a
> PKZIP file that contains one file, which must have been packed by shrinking
> ...
> #include <stdio.h>

 Sorry. A corrigendum. These lines:-

            else if(c==2) {pc++;
                for(m=256;m<0x10000;m++) b[a[m]]|=0x8000;
                for(m=0;m<0x10000;m++)
                  if(b[m]&0x8000) b[m]&=0x7fff; else a[m]=b[m]=0;
                  for(q=257;b[q];q++) if(q>=0x10000) break /* MOAN */;}
        for(l=0,j=c;j>255;j=j==q?p:a[j]) w[l++]=b[j]; w[l++]=j;
        a[q]=p; b[q]=j; if(c==q) w[0]=j; pn[q]=pc;

  should read:-

            else if(c==2) {pc++;
                for(m=256;m<0x10000;m++) b[m]&=0x7fff;
                for(m=256;m<0x10000;m++) if(a[m]>255) b[a[m]]|=0x8000;
                for(m=0;m<0x10000;m++) if(b[m]>=0) a[m]=b[m]=0;
                for(q=257;b[q];q++) if(q>=0x10000) break /* MOAN */;}
        for(l=0,j=c;j>255;j=j==q?p:a[j]) w[l++]=b[j]; w[l++]=j;
        a[q]=p; b[q]=j|0x8000; if(c==q) w[0]=j; pn[q]=pc;

or trouble may happen if the file is long or longish and contains \000 bytes.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019