checker: improve checking of a << b, when a and b are numbers (#12589)

This commit is contained in:
Delyan Angelov 2021-11-29 02:48:49 +02:00 committed by GitHub
parent fe37da31a8
commit 6d97b0a407
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 436 additions and 148 deletions

View file

@ -177,7 +177,7 @@ pub fn (mut ws Client) listen() ? {
ws.close(1002, 'close payload cannot be 1 byte') ?
return error('close payload cannot be 1 byte')
}
code := (int(msg.payload[0]) << 8) + int(msg.payload[1])
code := u16(msg.payload[0]) << 8 | u16(msg.payload[1])
if code in invalid_close_codes {
ws.close(1002, 'invalid close code: $code') ?
return error('invalid close code: $code')