-
Notifications
You must be signed in to change notification settings - Fork 65
IntegerParameterType: Fix Min/Max XML import overflow #375
Conversation
In case XML data for Min and Max values are wrongly set (out of range). The Import function is not checking out of range format. In order to avoid roll over some additional boundary check need to be done. For exemple if we have Sign integer on 8 bits and we set Max value to 200 the new code will initialize the Max value to 127. Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
@dwagner please have a look related to boundary check. |
This patch is fixing code formating according to clang Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we simply return an error when min/max values are incorrect?
parameter/IntegerParameterType.cpp
Outdated
type CIntegerParameterType::LimitValueAgainstRange(type value, | ||
type minValue, type maxValue) const | ||
{ | ||
if (value > maxValue) return(maxValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coding style:
if (condition) {
statement;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of today .xsd doesn't check the range. So this method allows to have same behavior as when we do not specify Min and Max.
In case of ERROR a tool should be provided in order to check XML mix/max range as I am not sure that the error will be explicit for a full platform XML loading.
parameter/IntegerParameterType.cpp
Outdated
|
||
// Limit Range accoridng to dynammic | ||
template <typename type> | ||
type CIntegerParameterType::LimitValueAgainstRange(type value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coding style: method names start with a lowercase letter.
Current coverage is 72.11% (diff: 88.46%)@@ master #375 diff @@
==========================================
Files 211 211
Lines 6683 6705 +22
Methods 1438 1439 +1
Messages 0 0
Branches 857 863 +6
==========================================
+ Hits 4814 4835 +21
+ Misses 1397 1396 -1
- Partials 472 474 +2
|
In case XML Min/Max values are not well set the import is returning error. Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
Minimum default value should be sign extended before boundary check. Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
This patch is improving IntegerParameter Type unit tests in order to check Min/max boundary when it is possible. Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
Due to Min and Max format storage the Size of Integer parameter should be limit to 32 bits. Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
Enhance unit test in order to check data size above 32 bits. Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
I've just merged #376, which covers the same issues. |
In case XML data for Min and Max values are wrongly set (out of range). The
Import function is not checking out of range format. In order to avoid
roll over some additional boundary check need to be done.
For exemple if we have Sign integer on 8 bits and we set Max value to 200
the new code will initialize the Max value to 127.
Signed-off-by: Sebastien Guiriec sebastien.guiriec@intel.com
