[gnumeric] xls: fuzzed file fix.



commit 5f43352c8c2756129099520944e8013da2f24a3f
Author: Morten Welinder <terra gnome org>
Date:   Sun Jan 3 17:51:04 2016 -0500

    xls: fuzzed file fix.

 NEWS                          |    2 +-
 plugins/excel/ChangeLog       |    5 +++++
 plugins/excel/ms-excel-read.c |   30 +++++++++++++++++-------------
 3 files changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/NEWS b/NEWS
index 0201481..75cf7a4 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,7 @@ Morten:
        * Teach ssconvert to split sheets into separate .txt files [#694408]
        * Improve test suite.
        * Fuzzed file fixes.  [#760046]  [#760085]  [#760087]  [#760089]
-         [#760043]
+         [#760043]  [#760103]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.26
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 557c74d..4c90dba 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2016-01-03  Morten Welinder  <terra gnome org>
+
+       * ms-excel-read.c (excel_sheet_new): Always create a new sheet.
+       Fixes #760103.
+
 2016-01-02  Morten Welinder  <terra gnome org>
 
        * ms-formula-read.c (excel_parse_formula1): Check for recursive
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 84e7b21..a8bf7bc 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -888,17 +888,17 @@ excel_sheet_new (GnmXLImporter *importer, char const *sheet_name, GnmSheetType t
 
        ExcelReadSheet *esheet = g_new (ExcelReadSheet, 1);
        Sheet *sheet;
-
-       sheet = workbook_sheet_by_name (importer->wb, sheet_name);
-       if (sheet == NULL) {
-               sheet = sheet_new_with_type (importer->wb, sheet_name, type,
-                                            XLS_MaxCol,
-                                            (importer->ver >= MS_BIFF_V8
-                                             ? XLS_MaxRow_V8
-                                             : XLS_MaxRow_V7));
-               workbook_sheet_attach (importer->wb, sheet);
-               d (1, g_printerr ("Adding sheet '%s'\n", sheet_name););
-       }
+       char *real_name;
+
+       real_name = workbook_sheet_get_free_name (importer->wb, sheet_name, FALSE, TRUE);
+       sheet = sheet_new_with_type (importer->wb, real_name, type,
+                                    XLS_MaxCol,
+                                    (importer->ver >= MS_BIFF_V8
+                                     ? XLS_MaxRow_V8
+                                     : XLS_MaxRow_V7));
+       workbook_sheet_attach (importer->wb, sheet);
+       d (1, g_printerr ("Adding sheet '%s'\n", real_name););
+       g_free (real_name);
 
        /* Flag a respan here in case nothing else does */
        sheet_flag_recompute_spans (sheet);
@@ -1524,9 +1524,11 @@ excel_read_BOUNDSHEET (BiffQuery *q, GnmXLImporter *importer)
         * It appears that if the name is null it defaults to Sheet%d?
         * However, we have only one test case and no docs.
         */
-       if (bs->name == NULL)
+       if (bs->name == NULL || bs->name[0] == 0) {
+               g_free (bs->name);
                bs->name = g_strdup_printf (default_name,
-                                           importer->boundsheet_sheet_by_index->len);
+                                           importer->boundsheet_sheet_by_index->len + 1);
+       }
 
        switch (bs->type) {
        case MS_BIFF_TYPE_Worksheet :
@@ -3184,6 +3186,7 @@ excel_sheet_destroy (ExcelReadSheet *esheet)
 {
        if (esheet == NULL)
                return;
+
        if (esheet->shared_formulae != NULL) {
                g_hash_table_destroy (esheet->shared_formulae);
                esheet->shared_formulae = NULL;
@@ -3913,6 +3916,7 @@ excel_prepare_autofilter (GnmXLImporter *importer, GnmNamedExpr *nexpr)
                                        if (esheet->sheet == r.sheet) {
                                                g_return_if_fail (esheet->filter == NULL);
                                                esheet->filter = filter;
+                                               break;
                                        }
                                }
                        }


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