named-data-iot/ndn-lite

Incorrect decoding of FreshnessPeriod

Closed this issue · 1 comments

As of 5b43c5f, ndn_metainfo_tlv_decode invokes:

else if (probe == TLV_FreshnessPeriod) {
  decoder_get_length(decoder, &probe);
  decoder_get_uint32_value(decoder, &meta->freshness_period);
  meta->enable_FreshnessPeriod = 1;
}

It assumes FreshnessPeriod has TLV-LENGTH=4 without checking it.
NDN Packet Format v0.3 specifies that FreshnessPeriod element is NonNegativeInteger that could have 1, 2, 4, or 8 octets.
Consequently, the decoding function would read FreshnessPeriod incorrectly if its TLV-LENGTH is not 4.

Commit 2ea899b will address this problem. new FreshnessPeriod is encoded/decoded in the same way as InterestLifetime in issue #29. Thank you for pointing this out.