소스 검색

followup to array acess breaches: waterobject and guiparticlegraphctrl need to check `>=`, not just `>`

AzaezelX 5 년 전
부모
커밋
6b2db37f8a
2개의 변경된 파일24개의 추가작업 그리고 24개의 파일을 삭제
  1. 1 1
      Engine/source/environment/waterObject.cpp
  2. 23 23
      Engine/source/gui/editor/guiParticleGraphCtrl.cpp

+ 1 - 1
Engine/source/environment/waterObject.cpp

@@ -1120,7 +1120,7 @@ bool WaterObject::initMaterial( S32 idx )
    // We must return false for any case which it is NOT safe for the caller
    // We must return false for any case which it is NOT safe for the caller
    // to use the indexed material.
    // to use the indexed material.
    
    
-   if ( idx < 0 || idx > NumMatTypes )
+   if ( idx < 0 || idx >= NumMatTypes )
       return false;
       return false;
 
 
    BaseMatInstance *mat = mMatInstances[idx];
    BaseMatInstance *mat = mMatInstances[idx];

+ 23 - 23
Engine/source/gui/editor/guiParticleGraphCtrl.cpp

@@ -440,7 +440,7 @@ S32 GuiParticleGraphCtrl::getSelectedPoint()
 
 
 bool GuiParticleGraphCtrl::isExistingPoint(S32 plotID, S32 sample)
 bool GuiParticleGraphCtrl::isExistingPoint(S32 plotID, S32 sample)
 {
 {
-   if (((plotID < 0) || (plotID > MaxPlots)) || ((sample < 0) || (sample > MaxDataPoints)) || (sample >= mPlots[plotID].mGraphData.size()))
+   if (((plotID < 0) || (plotID >= MaxPlots)) || ((sample < 0) || (sample > MaxDataPoints)) || (sample >= mPlots[plotID].mGraphData.size()))
    {
    {
       return false;
       return false;
    } else
    } else
@@ -455,7 +455,7 @@ Point2F GuiParticleGraphCtrl::getPlotPoint(S32 plotID, S32 sample)
    val.x = -1;
    val.x = -1;
    val.y = -1;
    val.y = -1;
 
 
-   if (((plotID < 0) || (plotID > MaxPlots)) || ((sample < 0) || (sample > MaxDataPoints)))
+   if (((plotID < 0) || (plotID >= MaxPlots)) || ((sample < 0) || (sample > MaxDataPoints)))
    {
    {
       return val;
       return val;
    }
    }
@@ -465,7 +465,7 @@ Point2F GuiParticleGraphCtrl::getPlotPoint(S32 plotID, S32 sample)
 
 
 S32 GuiParticleGraphCtrl::getPlotIndex(S32 plotID, F32 x, F32 y)
 S32 GuiParticleGraphCtrl::getPlotIndex(S32 plotID, F32 x, F32 y)
 {
 {
-   if ((plotID < 0) || (plotID > MaxPlots))
+   if ((plotID < 0) || (plotID >= MaxPlots))
    {
    {
       return -1;
       return -1;
    } 
    } 
@@ -1022,7 +1022,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setSelectedPlot, void, (S32 plotID), ,
               "Set the selected plot (a.k.a. graph)."
               "Set the selected plot (a.k.a. graph)."
            "@return No return value" )
            "@return No return value" )
 {
 {
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1034,7 +1034,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, clearGraph, void, (S32 plotID), , "(int
               "Clear the graph of the given plot."
               "Clear the graph of the given plot."
            "@return No return value")
            "@return No return value")
 {
 {
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1054,7 +1054,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, addPlotPoint, S32, (S32 plotID, F32 x,
            "@return")
            "@return")
 {
 {
   
   
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return -2;
       return -2;
@@ -1069,7 +1069,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, insertPlotPoint, void, (S32 plotID, S32
            "@param x,y The plot position.\n"
            "@param x,y The plot position.\n"
            "@return No return value.")
            "@return No return value.")
 {
 {
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1084,7 +1084,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, changePlotPoint, S32, (S32 plotID, S32
            "@param x,y The plot position.\n"
            "@param x,y The plot position.\n"
            "@return No return value.")
            "@return No return value.")
 {
 {
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return -1;
       return -1;
@@ -1110,7 +1110,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, isExistingPoint, bool, (S32 plotID, S32
               "@return Returns true or false whether or not the point in the plot passed is an existing point.")
               "@return Returns true or false whether or not the point in the plot passed is an existing point.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
    }
    }
@@ -1126,7 +1126,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, getPlotPoint, Point2F, (S32 plotID, S32
            "@return The data point ID")
            "@return The data point ID")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
    }
    }
@@ -1146,7 +1146,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, getPlotIndex, S32, (S32 plotID, F32 x,
            "@return Returns the index of the point.\n")
            "@return Returns the index of the point.\n")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
    }
    }
@@ -1158,7 +1158,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, getGraphColor, LinearColorF, (S32 plotI
            "@return Returns the color of the graph as a string of RGB values formatted as \"R G B\"")
            "@return Returns the color of the graph as a string of RGB values formatted as \"R G B\"")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
    }
    }
@@ -1172,7 +1172,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, getGraphMin, Point2F, (S32 plotID), , "
            "@return Returns the minimum of the range formatted as \"x-min y-min\"")
            "@return Returns the minimum of the range formatted as \"x-min y-min\"")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
    }
    }
@@ -1184,7 +1184,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, getGraphMax, Point2F, (S32 plotID), , "
            "@return Returns the maximum of the range formatted as \"x-max y-max\"")
            "@return Returns the maximum of the range formatted as \"x-max y-max\"")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
    }
    }
@@ -1197,7 +1197,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, getGraphName, const char*, (S32 plotID)
            "@return Returns the name of the plot")
            "@return Returns the name of the plot")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
    }
    }
@@ -1216,7 +1216,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setGraphMin, void, (S32 plotID, F32 min
            "@return No return value.")
            "@return No return value.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1232,7 +1232,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setGraphMinX, void, (S32 plotID, F32 mi
            "@return No return Value.")
            "@return No return Value.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1248,7 +1248,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setGraphMinY, void, (S32 plotID, F32 mi
            "@return No return Value.")
            "@return No return Value.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1264,7 +1264,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setGraphMax, void, (S32 plotID, F32 max
            "@return No return value.")
            "@return No return value.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1280,7 +1280,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setGraphMaxX, void, (S32 plotID, F32 ma
            "@return No return Value.")
            "@return No return Value.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1296,7 +1296,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setGraphMaxY, void, (S32 plotID, F32 ma
            "@return No return Value.")
            "@return No return Value.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1310,7 +1310,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setGraphHidden, void, (S32 plotID, bool
            "@return No return value.")
            "@return No return value.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;
@@ -1362,7 +1362,7 @@ DefineEngineMethod(GuiParticleGraphCtrl, setGraphName, void, (S32 plotID, const
            "@return No return value.")
            "@return No return value.")
 {
 {
 
 
-   if(plotID > object->MaxPlots)
+   if(plotID >= object->MaxPlots)
    {
    {
       Con::errorf("Invalid plotID.");
       Con::errorf("Invalid plotID.");
       return;
       return;