mirror of https://github.com/gorilla/websocket.git
Fix mask alignment
Fix incorrect computation of buffer alignment in maskBytes. With this change, all word operations on the buffer are aligned on word boundaries.
This commit is contained in:
parent
2aff870ef8
commit
343fff4c5c
2
mask.go
2
mask.go
|
@ -28,7 +28,7 @@ func maskBytes(key [4]byte, pos int, b []byte) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mask one byte at a time to word boundary.
|
// Mask one byte at a time to word boundary.
|
||||||
if n := int(uintptr(unsafe.Pointer(&b))) % wordSize; n != 0 {
|
if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 {
|
||||||
n = wordSize - n
|
n = wordSize - n
|
||||||
for i := range b[:n] {
|
for i := range b[:n] {
|
||||||
b[i] ^= key[pos&3]
|
b[i] ^= key[pos&3]
|
||||||
|
|
Loading…
Reference in New Issue