more bounds checks
This commit is contained in:
@@ -705,7 +705,7 @@ result_t StringDataField::writeSymbols(istringstream& input,
|
|||||||
if ((m_dataType.flags & BCD) != 0)
|
if ((m_dataType.flags & BCD) != 0)
|
||||||
output[baseOffset + offset - incr] = (unsigned char)((6+daysSinceSunday) % 7); // Sun=0x06
|
output[baseOffset + offset - incr] = (unsigned char)((6+daysSinceSunday) % 7); // Sun=0x06
|
||||||
else
|
else
|
||||||
output[baseOffset + offset - incr] = (daysSinceSunday==0 ? 7 : daysSinceSunday); // Sun=0x07
|
output[baseOffset + offset - incr] = (unsigned char)(daysSinceSunday==0 ? 7 : daysSinceSunday); // Sun=0x07
|
||||||
}
|
}
|
||||||
if (value >= 2000)
|
if (value >= 2000)
|
||||||
value -= 2000;
|
value -= 2000;
|
||||||
@@ -891,7 +891,7 @@ NumberDataField::NumberDataField(const string name, const string comment,
|
|||||||
const unsigned char length, const unsigned char bitCount,
|
const unsigned char length, const unsigned char bitCount,
|
||||||
const int divisor)
|
const int divisor)
|
||||||
: NumericDataField(name, comment, unit, dataType, partType, length, bitCount,
|
: NumericDataField(name, comment, unit, dataType, partType, length, bitCount,
|
||||||
(dataType.bitCount % 8) == 0 ? 0 : (unsigned char)dataType.divisorOrFirstBit),
|
(unsigned char)((dataType.bitCount % 8) == 0 ? 0 : dataType.divisorOrFirstBit)),
|
||||||
m_divisor(divisor), m_precision(0)
|
m_divisor(divisor), m_precision(0)
|
||||||
{
|
{
|
||||||
if (divisor > 1)
|
if (divisor > 1)
|
||||||
|
|||||||
+2
-2
@@ -305,7 +305,7 @@ public:
|
|||||||
PartType getPartType() const { return m_partType; }
|
PartType getPartType() const { return m_partType; }
|
||||||
|
|
||||||
// @copydoc
|
// @copydoc
|
||||||
virtual unsigned char getLength(PartType partType) { return partType == m_partType ? m_length : 0; };
|
virtual unsigned char getLength(PartType partType) { return partType == m_partType ? m_length : (unsigned char)0; };
|
||||||
// re-use same position as previous field as not all bits of fully consumed yet
|
// re-use same position as previous field as not all bits of fully consumed yet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -557,7 +557,7 @@ public:
|
|||||||
const unsigned char length, const unsigned char bitCount,
|
const unsigned char length, const unsigned char bitCount,
|
||||||
const map<unsigned int, string> values)
|
const map<unsigned int, string> values)
|
||||||
: NumericDataField(name, comment, unit, dataType, partType, length, bitCount,
|
: NumericDataField(name, comment, unit, dataType, partType, length, bitCount,
|
||||||
(dataType.bitCount < 8) ? (unsigned char)dataType.divisorOrFirstBit : 0),
|
(unsigned char)((dataType.bitCount < 8) ? dataType.divisorOrFirstBit : 0)),
|
||||||
m_values(values) {}
|
m_values(values) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user