Commit bda5371
authored
Reject MessagePack/BSON binary subtypes that don't fit their wire format
Both formats store byte_container_with_subtype's subtype (a uint64_t)
in a single byte. The writers cast to std::int8_t/std::uint8_t without
a range check, so subtypes above 255 were silently truncated modulo
256 instead of raising an error. Throw out_of_range.413 instead when
the subtype exceeds the representable range of 0-255.
Signed-off-by: Niels Lohmann <mail@nlohmann.me>1 parent eaf52bd commit bda5371
4 files changed
Lines changed: 59 additions & 0 deletions
File tree
- docs/mkdocs/docs/home
- include/nlohmann/detail/output
- single_include/nlohmann
- tests/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
933 | 933 | | |
934 | 934 | | |
935 | 935 | | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
936 | 947 | | |
937 | 948 | | |
938 | 949 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
691 | 696 | | |
692 | 697 | | |
693 | 698 | | |
| |||
1187 | 1192 | | |
1188 | 1193 | | |
1189 | 1194 | | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1190 | 1201 | | |
1191 | 1202 | | |
1192 | 1203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17775 | 17775 | | |
17776 | 17776 | | |
17777 | 17777 | | |
| 17778 | + | |
| 17779 | + | |
| 17780 | + | |
| 17781 | + | |
| 17782 | + | |
17778 | 17783 | | |
17779 | 17784 | | |
17780 | 17785 | | |
| |||
18274 | 18279 | | |
18275 | 18280 | | |
18276 | 18281 | | |
| 18282 | + | |
| 18283 | + | |
| 18284 | + | |
| 18285 | + | |
| 18286 | + | |
| 18287 | + | |
18277 | 18288 | | |
18278 | 18289 | | |
18279 | 18290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1668 | 1668 | | |
1669 | 1669 | | |
1670 | 1670 | | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
1671 | 1697 | | |
0 commit comments