Skip to content

Commit

Permalink
fix: add more stringent validation when building _incomingBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
cdenig committed Sep 28, 2023
1 parent f10e70f commit 892f2b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions epi-display-samsung-mdc/SamsungMdc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ private void Communication_BytesReceived(object sender, GenericCommMethodReceive
// following string format from building unnecessarily on level 0 or 1
Debug.Console(DebugLevelVerbose, this, "Received new bytes:{0}", ComTextHelper.GetEscapedText(newBytes));
}

// Get data length
if (newBytes.Length >= 6)
{
Expand All @@ -454,7 +453,7 @@ private void Communication_BytesReceived(object sender, GenericCommMethodReceive
return;
}
}
if (newBytes[0] == 0xAA)
if (newBytes[0] == 0xAA && newBytes[1] == 0xFF && newBytes[2] == Id)
{
_incomingBuffer = newBytes;
if (Debug.Level == 2)
Expand All @@ -467,6 +466,11 @@ private void Communication_BytesReceived(object sender, GenericCommMethodReceive
{
byte[] clear = { };
_incomingBuffer = clear;
if (Debug.Level == 2)
{
// This check is here to prevent following string format from building unnecessarily on level 0 or 1
Debug.Console(DebugLevelVerbose, this, "Unsupported response recieved:{0}", ComTextHelper.GetEscapedText(newBytes));
}
}
}
catch (Exception ex)
Expand Down

0 comments on commit 892f2b1

Please sign in to comment.