Skip to content

MsgPack: support full UInt64 range when decoding #10

@wdoo01

Description

@wdoo01

Hi, thanks for DDO — it works very well overall.

I noticed an issue when decoding MsgPack uint64 values at the upper end of the range. For example, decoding UInt64.MaxValue raises an exception:

is too large of an unsigned 64-bit integer to fit in a signed 64-bit integer type.

I traced this to DataObjects2MsgPack.pas, where large uint64 values are explicitly rejected:

$cf: begin  // uInt 64
  fStream.Read(lUInt64, 8);
  lUInt64 := SwapBytes(lUInt64);
  if lUInt64 <= $7FFFFFFFFFFFFFFF then
    aDataObj.AsInt64 := lUInt64
  else
    raise Exception.Create(IntToHex(lUInt64)+' is too large of an unsigned 64-bit integer to fit in a signed 64-bit integer type.');
end;

From the codebase, it seems TDataObj already has a SetAsUInt64 method. Because of that, I wanted to ask:

  • Is there a design reason why MsgPack decoding does not support the full UInt64 range?
  • Would it be possible to decode $cf values larger than Int64.MaxValue via AsUInt64 instead of raising an exception?

It would be great if DDO could support the full MsgPack uint64 range.

If helpful, I can also put together a minimal repro case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions