Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
handle badly formed u64 data
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jan 21, 2022
1 parent b960196 commit 1932251
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Jacdac/PacketEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ public static object[] UnPack(string fmt, byte[] buf)
var nf = Util.NumberFormatOfType(fmt);
if (nf != NumberFormat.Unknown)
{
// special case u32 as u64
if (nf == NumberFormat.UInt64LE && buf.Length == 4)
return new object[] { (ulong)(uint)Util.GetNumber(buf, NumberFormat.UInt32LE, 0) };
var sz = Util.SizeOfNumberFormat(nf);
if (buf.Length == sz)
return new object[] { Util.GetNumber(buf, nf, 0) };
Expand Down

0 comments on commit 1932251

Please sign in to comment.