[evolution-ews/gnome-3-8] Bug 699241 - GAL decompression fails due to invalid window_size calculation



commit d24296720ae2f61e97e1c37b5b1fa2e261458853
Author: David Woodhouse <David Woodhouse intel com>
Date:   Thu May 2 16:55:49 2013 +0100

    Bug 699241 - GAL decompression fails due to invalid window_size calculation
    
    I have no idea why this calculation was so baroque in the first place.
    This appears to fix it for all the test files I've collected, and makes
    it a lot simpler.
    (cherry picked from commit 34478cc32cb10b49f7dad0adcec512714e9c904e)

 src/addressbook/lzx/ews-oal-decompress.c |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/src/addressbook/lzx/ews-oal-decompress.c b/src/addressbook/lzx/ews-oal-decompress.c
index 219c2c1..a97f347 100644
--- a/src/addressbook/lzx/ews-oal-decompress.c
+++ b/src/addressbook/lzx/ews-oal-decompress.c
@@ -207,24 +207,17 @@ oal_decompress_v4_full_detail_file (const gchar *filename,
                        }
                        g_free (buffer);
                } else {
-                       /* round to multiples of 32768 */
-                       guint mul, round, set, window_bits;
+                       /* The window size should be the smallest power of two between 2^17 and 2^25 that is
+                          greater than or equal to the sum of the size of the reference data rounded up to
+                          a multiple of 32768 and the size of the subject data. Since we have no reference
+                          data, forget that and the rounding. Just the smallest power of two which is large
+                          enough to cover the subject data (lzx_b->ucomp_size). */
 
-                       mul = ceil (lzx_b->ucomp_size / 32768.0);
-                       round = mul * 32768;
-                       set = g_bit_nth_lsf ((round >> 17), -1);
+                       guint window_bits = g_bit_nth_msf(lzx_b->ucomp_size - 1, -1) + 1;
 
-                       if (set > 8)
-                               window_bits = 25;
-                       else if (set == 0 && !(round >> 17))
+                       if (window_bits < 17)
                                window_bits = 17;
-                       else {
-                               window_bits = set + 17;
-                               if (round % (2^window_bits))
-                                       window_bits++;
-                       }
-
-                       if (window_bits > 25)
+                       else if (window_bits > 25)
                                window_bits = 25;
 
                        lzs = lzxd_init (input, output, window_bits, 0, 16, lzx_b->ucomp_size);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]