nano icon indicating copy to clipboard operation
nano copied to clipboard

MessageHeader uses incorrect extensions size?

Open paulmelis opened this issue 7 years ago • 1 comments

I was working on parsing the UDP packets being sent on the Nano network (not related to your implementation). I seem to get some malformed package headers, with respect to the extensions field, although it's hard to tell without a clear specification.

Reading the Nano code, specifically https://github.com/nanocurrency/raiblocks/blob/8caed829b461b015141d2dcd57d9b3457ba0f7f0/rai/node/common.cpp#L53, it seems the extensions field uses 2 bytes. But in your code, https://github.com/frankh/nano/blob/078a99b8e75bd239e13565312e06258164a781d5/node/node.go#L55, I see you use 1 byte. Have you tested your code on the actual packets flying around, and did it parse them correctly?

paulmelis avatar Mar 22 '18 08:03 paulmelis

Ah, I now see what's going: the block type is stuffed in 8 bits of the extensions value (https://github.com/nanocurrency/raiblocks/blob/8caed829b461b015141d2dcd57d9b3457ba0f7f0/rai/node/common.cpp#L33)

paulmelis avatar Mar 22 '18 10:03 paulmelis