()
| 721 | /// Feed two-byte patterns to cover tag + partial payload (truncated). |
| 722 | #[test] |
| 723 | fn fuzz_two_byte_patterns() { |
| 724 | // Tags that expect more bytes than we provide |
| 725 | let tags_need_extra: &[u8] = &[ |
| 726 | 0xca, // FLOAT32 needs 4 more |
| 727 | 0xcb, // FLOAT64 needs 8 more |
| 728 | 0xcc, // UINT8 needs 1 more |
| 729 | 0xcd, // UINT16 needs 2 more |
| 730 | 0xce, // UINT32 needs 4 more |
| 731 | 0xcf, // UINT64 needs 8 more |
| 732 | 0xd0, // INT8 needs 1 more |
| 733 | 0xd1, // INT16 needs 2 more |
| 734 | 0xd2, // INT32 needs 4 more |
| 735 | 0xd3, // INT64 needs 8 more |
| 736 | 0xd9, // STR8 length byte then data |
| 737 | 0xda, // STR16 2-byte length then data |
| 738 | 0xdb, // STR32 4-byte length then data |
| 739 | 0xdc, // ARRAY16 2-byte count then elements |
| 740 | 0xdd, // ARRAY32 4-byte count then elements |
| 741 | 0xde, // MAP16 2-byte count then pairs |
| 742 | 0xdf, // MAP32 4-byte count then pairs |
| 743 | 0xc4, // BIN8 |
| 744 | 0xc5, // BIN16 |
| 745 | 0xc6, // BIN32 |
| 746 | 0xd4, // FIXEXT1 |
| 747 | 0xd5, // FIXEXT2 |
| 748 | 0xd6, // FIXEXT4 |
| 749 | 0xd7, // FIXEXT8 |
| 750 | 0xd8, // FIXEXT16 |
| 751 | ]; |
| 752 | for &tag in tags_need_extra { |
| 753 | // Single byte (completely truncated payload) |
| 754 | let buf = [tag]; |
| 755 | let _ = skip_value(&buf, 0); |
| 756 | let _ = read_f64(&buf, 0); |
| 757 | let _ = read_i64(&buf, 0); |
| 758 | let _ = read_value(&buf, 0); |
| 759 | |
| 760 | // Tag + one garbage byte |
| 761 | for second in [0x00u8, 0x01, 0x7f, 0x80, 0xff] { |
| 762 | let buf = [tag, second]; |
| 763 | let _ = skip_value(&buf, 0); |
| 764 | let _ = read_f64(&buf, 0); |
| 765 | let _ = read_i64(&buf, 0); |
| 766 | let _ = read_value(&buf, 0); |
| 767 | } |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | /// Deterministic pseudo-random byte sequences must not cause panics. |
| 772 | #[test] |
nothing calls this directly
no test coverage detected