RESEND: winhelp: bug fix in LZ77 decompressor

lich_at_math lich at math.spbu.ru
Tue Aug 8 07:34:32 CDT 2006


>
>   Hi,
>
>   ChangeLog:
>     Fix rather unusual bug in LZ77 decompressor. We cannot use memcpy
>     with overlapped areas because of unpredictable result. We must copy
>     byte-by-byte.
>
   We cannot use memmove/bcopy too (different functionality).
Now, attach file correctly.

Index: programs/winhelp/hlpfile.c
===================================================================
RCS file: /home/wine/wine/programs/winhelp/hlpfile.c,v
retrieving revision 1.29
diff -u -p -r1.29 hlpfile.c
--- programs/winhelp/hlpfile.c  23 May 2006 12:49:31 -0000      1.29
+++ programs/winhelp/hlpfile.c  8 Aug 2006 10:07:01 -0000
@@ -1498,8 +1498,14 @@ static BYTE *HLPFILE_UncompressLZ77(BYTE
                  int code   = GET_USHORT(ptr, 0);
                  int len    = 3 + (code >> 12);
                  int offset = code & 0xfff;
-                memcpy(newptr, newptr - offset - 1, len);
-                newptr += len;
+                /*
+                 * We must copy byte-by-byte here. We cannot use memcpy  
here,
+                 * because areas are overlaps, so it's behaviour is
+                 * unpredictable (memcpy DOES NOT copy byte-by-byte  
because of
+                 * some optimizations).
+                 * bcopy also fails, it behaves like memmove, non memcpy.
+                 */
+                for (; len>0; len--, newptr++) *newptr =  
*(newptr-offset-1);
                  ptr    += 2;
             }
              else *newptr++ = *ptr++;



More information about the wine-patches mailing list