pkstrings: prevent addition from overflowing
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
cc723f7684
commit
a82d73122d
1 changed files with 3 additions and 3 deletions
|
@ -57,14 +57,14 @@ const fn strtohex(chr: &char) -> Option<u8> {
|
|||
|
||||
const fn hextostr(hex: u8) -> Option<char> {
|
||||
Some(match hex {
|
||||
cap @ 0x80..=0x99 => (('A' as u8) + cap - 0x80) as char,
|
||||
cap @ 0x80..=0x99 => (('A' as u8) + (cap - 0x80)) as char,
|
||||
0x9a => '(',
|
||||
0x9b => ')',
|
||||
0x9c => ':',
|
||||
0x9d => ';',
|
||||
0x9e => '[',
|
||||
0x9f => ']',
|
||||
low @ 0xa0..=0xb9 => (('a' as u8) + low - 0xa0) as char,
|
||||
low @ 0xa0..=0xb9 => (('a' as u8) + (low - 0xa0)) as char,
|
||||
0xe0 => '\'',
|
||||
0xe3 => '-',
|
||||
0xe6 => '?',
|
||||
|
@ -79,7 +79,7 @@ const fn hextostr(hex: u8) -> Option<char> {
|
|||
0xf3 => '/',
|
||||
0xf4 => ',',
|
||||
0xf5 => '♀',
|
||||
num @ 0xf6..=0xff => (('0' as u8) + num - 0xf6) as char,
|
||||
num @ 0xf6..=0xff => (('0' as u8) + (num - 0xf6)) as char,
|
||||
0x7f => ' ',
|
||||
0x50 => '@',
|
||||
_ => return None,
|
||||
|
|
Loading…
Reference in a new issue