rusticata / der-parser

BER/DER parser written in pure Rust. Fast, zero-copy, safe.
Apache License 2.0
85 stars 28 forks source link

fix/correctly-handle-oids-starting-with-two-zeroes: Correctly handle OIDs starting with two zero subidentifiers (literally "itu-t recommendation") #33

Closed p1-mmr closed 4 years ago

p1-mmr commented 4 years ago

This pull request will allow to correctly handle OIDs starting with two zero subidentifiers (literally "itu-t recommendation").

Here in an example of such an OID definition from the ASN.1 definitions for the TCAP (Q.773) protocol:

dialogue-as-id OBJECT IDENTIFIER ::=
  {itu-t recommendation q 773 as(1) dialogue-as(1) version1(1)}

Previously, they were incorrectly decoded or represented as just "0" due to a bug in the library (they were interpreted just as when they contained only one octet which was "\x00", which was alleged to mean "only one subidentifier being 0", because of a missing conditional check on the raw OID byte length in the code when handling this special case).

The corresponding test case was also added to the code so that the issue is ensured to be fixed.

chifflier commented 4 years ago

Indeed, the iterator loop was exiting due to a missing check on remaining items. Applied, thanks!