Open-Markets-Initiative / wireshark-lua

Source generated cross platform Wireshark dissectors
GNU General Public License v3.0
184 stars 63 forks source link

Nasdaq dissector(s) using variable named "display" #34

Closed selavy closed 1 year ago

selavy commented 2 years ago

Issue

OUCH has a field named "display" (see "2.1 Enter Order Message" in the spec), which causes the generator to assign to a variable named "display" overwriting the display table.

Example

https://github.com/Open-Markets-Initiative/wireshark-lua/blob/3d9c908726e646faff83640e4a6c52b2de38fa18/Nasdaq/Nasdaq.Equities.Orders.Ouch.v4.2.Script.Dissector.lua#L588

Temporary workaround for users:

For end users, doing `s/, display =/, display_ =/g' will work.

Fix

In code like this:

-- Dissect Fields: Order Priority Update Message
dissect.order_priority_update_message_fields = function(buffer, offset, packet, parent)
  local index = offset

  -- Timestamp: 8 Byte Unsigned Fixed Width Integer
  index, timestamp = dissect.timestamp(buffer, index, packet, parent)

  -- Order Token: 14 Byte Ascii String
  index, order_token = dissect.order_token(buffer, index, packet, parent)

  -- Price: 4 Byte Unsigned Fixed Width Integer
  index, price = dissect.price(buffer, index, packet, parent)

  -- Display: 1 Byte Ascii String Enum with 13 values
  index, display = dissect.display(buffer, index, packet, parent)  -- <<<<<<<<<

  -- Order Reference Number: 8 Byte Unsigned Fixed Width Integer
  index, order_reference_number = dissect.order_reference_number(buffer, index, packet, parent)

  return index
end

https://github.com/Open-Markets-Initiative/wireshark-lua/blob/3d9c908726e646faff83640e4a6c52b2de38fa18/Nasdaq/Nasdaq.Equities.Orders.Ouch.v4.2.Script.Dissector.lua#L574

The return values for the calls to dissect should be marked local:

-- Dissect Fields: Order Priority Update Message
dissect.order_priority_update_message_fields = function(buffer, offset, packet, parent)
  local index = offset

  -- Timestamp: 8 Byte Unsigned Fixed Width Integer
  local index, timestamp = dissect.timestamp(buffer, index, packet, parent)

  -- Order Token: 14 Byte Ascii String
  local index, order_token = dissect.order_token(buffer, index, packet, parent)

  -- Price: 4 Byte Unsigned Fixed Width Integer
  local index, price = dissect.price(buffer, index, packet, parent)

  -- Display: 1 Byte Ascii String Enum with 13 values
  local index, display = dissect.display(buffer, index, packet, parent)

  -- Order Reference Number: 8 Byte Unsigned Fixed Width Integer
  local index, order_reference_number = dissect.order_reference_number(buffer, index, packet, parent)

  return index
end
Open-Markets-Initiative commented 2 years ago

Thanks for bringing this to our attention. Some of the multi return values are experimental. We need to think about the best solution here.

Open-Markets-Initiative commented 1 year ago

Finally fixed in: https://github.com/Open-Markets-Initiative/wireshark-lua/commit/849133c9e0590456438726c80b499cd632432bc7