[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/source

Caolán McNamara caolanm at redhat.com
Tue Mar 13 12:14:34 UTC 2018


 sc/source/ui/inc/viewdata.hxx  |    4 ++--
 sc/source/ui/view/viewdata.cxx |   12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 05315e34c354b84409aa5e29ce9b8ce494570b52
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 12 12:32:52 2018 +0000

    forcepoint #26 check input against max valid enum values
    
    Change-Id: Ide72884c77904ae9495b5189cde086e43923e4bd
    Reviewed-on: https://gerrit.libreoffice.org/51138
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 0c0613526d8f..dd9c7f144358 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -40,9 +40,9 @@ enum class ScFillMode
     MATRIX      = 4,
 };
 
-enum ScSplitMode { SC_SPLIT_NONE = 0, SC_SPLIT_NORMAL, SC_SPLIT_FIX };
+enum ScSplitMode { SC_SPLIT_NONE = 0, SC_SPLIT_NORMAL, SC_SPLIT_FIX, SC_SPLIT_MODE_MAX_ENUM = SC_SPLIT_FIX };
 
-enum ScSplitPos { SC_SPLIT_TOPLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_BOTTOMRIGHT };
+enum ScSplitPos { SC_SPLIT_TOPLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_BOTTOMRIGHT, SC_SPLIT_POS_MAX_ENUM = SC_SPLIT_BOTTOMRIGHT };
 enum ScHSplitPos { SC_SPLIT_LEFT, SC_SPLIT_RIGHT };
 enum ScVSplitPos { SC_SPLIT_TOP, SC_SPLIT_BOTTOM };
 
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index e0fe575a7d27..fc79f7f3e55e 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -207,13 +207,13 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV
         }
         else if (sName == SC_HORIZONTALSPLITMODE)
         {
-            aSettings[i].Value >>= nTemp16;
-            eHSplitMode = static_cast<ScSplitMode>(nTemp16);
+            if ((aSettings[i].Value >>= nTemp16) && nTemp16 <= ScSplitMode::SC_SPLIT_MODE_MAX_ENUM)
+                eHSplitMode = static_cast<ScSplitMode>(nTemp16);
         }
         else if (sName == SC_VERTICALSPLITMODE)
         {
-            aSettings[i].Value >>= nTemp16;
-            eVSplitMode = static_cast<ScSplitMode>(nTemp16);
+            if ((aSettings[i].Value >>= nTemp16) && nTemp16 <= ScSplitMode::SC_SPLIT_MODE_MAX_ENUM)
+                eVSplitMode = static_cast<ScSplitMode>(nTemp16);
         }
         else if (sName == SC_HORIZONTALSPLITPOSITION)
         {
@@ -237,8 +237,8 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV
         }
         else if (sName == SC_ACTIVESPLITRANGE)
         {
-            aSettings[i].Value >>= nTemp16;
-            eWhichActive = static_cast<ScSplitPos>(nTemp16);
+            if ((aSettings[i].Value >>= nTemp16) && nTemp16 <= ScSplitPos::SC_SPLIT_POS_MAX_ENUM)
+                eWhichActive = static_cast<ScSplitPos>(nTemp16);
         }
         else if (sName == SC_POSITIONLEFT)
         {


More information about the Libreoffice-commits mailing list