[libgsf] ole: fix seeking in small blocks.



commit 0393867759100fffa4487195ea2e2e7958e4f6c3
Author: Morten Welinder <terra gnome org>
Date:   Mon Dec 17 10:14:56 2018 -0500

    ole: fix seeking in small blocks.
    
    The code the turned small blocks into big blocks on demand had problems
    if the current offset was not at the end of the small block.

 ChangeLog               | 5 +++++
 gsf/gsf-outfile-msole.c | 7 +++++++
 2 files changed, 12 insertions(+)
---
diff --git a/ChangeLog b/ChangeLog
index 5a37296..cab4dbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-17  Morten Welinder  <terra gnome org>
+
+       * gsf/gsf-outfile-msole.c (gsf_outfile_msole_write): Fix problem
+       with seeks in small blocks.  This alone would also have fixed #14.
+
 2018-12-16  Morten Welinder  <terra gnome org>
 
        * gsf/gsf-msole-utils.c (msole_prop_parse): Don't convert the
diff --git a/gsf/gsf-outfile-msole.c b/gsf/gsf-outfile-msole.c
index 7f47592..dd27f41 100644
--- a/gsf/gsf-outfile-msole.c
+++ b/gsf/gsf-outfile-msole.c
@@ -604,6 +604,13 @@ gsf_outfile_msole_write (GsfOutput *output,
                }
                gsf_output_write (ole->sink, wsize, buf);
                g_free (buf);
+
+               // If we had a seek then we might not be at the right location.
+               // This can happen both with a seek beyond the end of file
+               // (see bug #14) and with a backward seek.
+               gsf_output_seek (ole->sink,
+                                ole->content.big_block.start_offset + output->cur_offset,
+                                G_SEEK_SET);
        }
 
        g_return_val_if_fail (ole->type == MSOLE_BIG_BLOCK, FALSE);


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