[PATCH 1/2] inflate_codes(): Add fix from upstream gzip to prevent false CRC error

Joakim Tjernlund joakim.tjernlund at transmode.se
Sun Feb 14 16:38:23 UTC 2010


Rob Landley <rob at landley.net> wrote on 2010/02/14 10:05:42:
>
> On Thursday 11 February 2010 16:57:36 Denys Vlasenko wrote:
> > On Monday 08 February 2010 18:55, Joakim Tjernlund wrote:
> > > Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
> > > ---
> > >  archival/libunarchive/decompress_unzip.c |    5 ++++-
> > >  1 files changed, 4 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/archival/libunarchive/decompress_unzip.c
> > > b/archival/libunarchive/decompress_unzip.c index feaa047..c616202 100644
> > > --- a/archival/libunarchive/decompress_unzip.c
> > > +++ b/archival/libunarchive/decompress_unzip.c
> > > @@ -575,13 +575,16 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY)
> > >           do {
> > >              /* Was: nn -= (e = (e = GUNZIP_WSIZE - ((dd &= GUNZIP_WSIZE - 1) > w
> > > ? dd : w)) > nn ? nn : e); */ /* Who wrote THAT?? rewritten as: */
> > > +            unsigned int delta;
> > > +
> > >              dd &= GUNZIP_WSIZE - 1;
> > >              e = GUNZIP_WSIZE - (dd > w ? dd : w);
> > > +            delta = w > dd ? w - dd : dd - w;
> > >              if (e > nn) e = nn;
> > >              nn -= e;
> > >
> > >              /* copy to new buffer to prevent possible overwrite */
> > > -            if (w - dd >= e) {   /* (this test assumes unsigned comparison) */
> > > +            if (delta >= e) {
> > >                 memcpy(gunzip_window + w, gunzip_window + dd, e);
> > >                 w += e;
> > >                 dd += e;
> >
> > Applied, thanks!
>
> The last gplv2-compatible release of gzip was 1.3.12, released in 2007.  Both
> 1.3.13 and 1.4 are GPLv3-only.  The above is a diff from 1.3.13 to 1.4,
> including the name of the new variable "delta".
>
> So it looks like you've just introduced gplv3-only code into BusyBox, which
> conflicts with the license on the Linux kernel, including code like ifenslave.c
> which came from the kernel's Documentation directory.

Oops, but on the other hand there is nothing unique about that snippet. I would
probably have written it the same way, possibly with another variable name.
You could rename it "dist" (for distance) if you like.

>
> There's a reason the Linux kernel uses the zlib deflate implementatin, which is
> bsd licensed.

That and it is better structured.



More information about the busybox mailing list