File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -101,18 +101,22 @@ func (hp *HopPayload) Decode(r io.Reader) error {
101101
102102 var payloadSize uint16
103103
104- // If the HopPayload isn't guaranteed to be a TLV payload, we check the
105- // first byte to see if it is a legacy payload.
106- if hp .Type != PayloadTLV && isLegacyPayloadByte (peekByte [0 ]) {
104+ // If the HopPayload might be a legacy payload (indicated by the Type
105+ // being equal to the zero-value PayloadLegacy), we check the first
106+ // byte to see if it is a legacy payload.
107+ if hp .Type == PayloadLegacy && isLegacyPayloadByte (peekByte [0 ]) {
107108 payloadSize = legacyPayloadSize ()
108109 } else {
109- // If the first byte doesn't indicate a legacy payload, then it
110- // *must* be a TLV payload.
110+ // Either this is already known to be a TLV payload, or the
111+ // first byte indicates that this is a TLV payload (i.e., the
112+ // first byte is not 0x00).
111113 payloadSize , err = tlvPayloadSize (bufReader )
112114 if err != nil {
113115 return err
114116 }
115117
118+ // We still need to set the payload type in case it was the
119+ // zero-value, PayloadLegacy, AND the first byte was not 0x00.
116120 hp .Type = PayloadTLV
117121 }
118122
You can’t perform that action at this time.
0 commit comments