Commit ed80e36
fix(oid): reject OIDs whose second arc exceeds 39 under first arc 0/1
is_valid_oid only checked slice[0] <= MAX_OID_FIRST_OCTET (first arc <= 2). It
never enforced the X.660/X.690 rule that when the first arc is 0 or 1 the second
arc must be <= 39. Because the integer-packed codecs encode the first two arcs as
first*40 + second, a larger second arc silently aliases onto a different OID:
ObjectIdentifier::new(vec![0, 40]) was accepted, encoded, and decoded back as 1.0
(and 0.999 -> 2.919) - an OID-confusion issue where two distinct constructed
values collapse to the same encoding.
Reject the invalid second arc at construction, mirroring the existing first-arc
guard (const-fn safe). MAX_OID_SECOND_OCTET already existed and was used in the
codec math; this reuses it in the validator. First arc 2 keeps its unbounded
second arc; single-arc OIDs still accepted; new_unchecked left untouched.
Tightening construction revealed four XER round-trip fixtures that themselves used
invalid OIDs (1.654.2.1, 1.8270.4.1); updated to valid equivalents (top-level arc
2, which has no second-arc bound) preserving multi-byte-arc coverage.
Fixes #5651 parent 3568553 commit ed80e36
2 files changed
Lines changed: 32 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
9 | 20 | | |
10 | 21 | | |
11 | 22 | | |
| |||
801 | 812 | | |
802 | 813 | | |
803 | 814 | | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
804 | 827 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
| 405 | + | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
| 552 | + | |
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| |||
0 commit comments