| 893 | break; |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | bool NetworkMessageRaw::Get(bool& value, NetworkCompressionType compression) |
| 898 | { |
| 899 | switch (compression) |
| 900 | { |
| 901 | case NCTNone: |
| 902 | case NCTDefault: |
| 903 | { |
| 904 | // Read into a byte and normalize: a tampered wire byte (e.g. 136) |
| 905 | // memcpy'd straight into a bool's storage is an out-of-range bool, |
| 906 | // and any later load of it is undefined behaviour. |
| 907 | unsigned char raw = 0; |
| 908 | if (!Read(&raw, sizeof(raw))) |
| 909 | return false; |
| 910 | value = (raw != 0); |
| 911 | return true; |
| 912 | } |
| 913 | default: |
| 914 | LOG_ERROR(Network, "Unsupported compression method {}", (int)compression); |
| 915 | return false; |
| 916 | } |
| 917 | } |
| 918 |
no test coverage detected