Skip to content

Commit

Permalink
Fixed potential buffer overrun in HwSetVehicleID.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesharrow committed Dec 13, 2023
1 parent 5b7f089 commit 234e956
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ Status EnergyEvseDelegate::HwSetRFID(ByteSpan uid)
*/
Status EnergyEvseDelegate::HwSetVehicleID(const CharSpan & newValue)
{
if ((mVehicleID.IsNull()) || (strcmp(newValue.data(), mVehicleID.Value().data()) != 0))
if (mVehicleID.IsNull() || !newValue.data_equal(mVehicleID.Value()))
{
/* create a copy of the string so the callee doesn't have to keep it */
char * destinationBuffer = new char[kMaxVehicleIDBufSize];
Expand All @@ -403,7 +403,7 @@ Status EnergyEvseDelegate::HwSetVehicleID(const CharSpan & newValue)

mVehicleID = MakeNullable(static_cast<CharSpan>(destinationString));

ChipLogDetail(AppServer, "VehicleID updated to %s", mVehicleID.Value().data());
ChipLogDetail(AppServer, "VehicleID updated");
MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, VehicleID::Id);
}

Expand Down

0 comments on commit 234e956

Please sign in to comment.