Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: fix errors found by vet #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func GetSNIBlock(data []byte) ([]byte, error) {
if index >= len(data) {
break
}
length := int((data[index] << 8) + data[index+1])
length := int(data[index])<<8 + data[index+1]
endIndex := index + 2 + length
if data[index+2] == 0x00 { /* SNI */
sni := data[index+3:]
sniLength := int((sni[0] << 8) + sni[1])
sniLength := int(sni[0])<<8 + sni[1]
return sni[2 : sniLength+2], nil
}
index = endIndex
Expand All @@ -81,14 +81,14 @@ func GetSNBlock(data []byte) ([]byte, error) {
return []byte{}, fmt.Errorf("Not enough bytes to be an SN block")
}

extensionLength := int((data[index] << 8) + data[index+1])
extensionLength := int(data[index])<<8 + data[index+1]
data = data[2 : extensionLength+2]

for {
if index >= len(data) {
break
}
length := int((data[index+2] << 8) + data[index+3])
length := int(data[index+2])<<8 + int(data[index+3])
endIndex := index + 4 + length
if data[index] == 0x00 && data[index+1] == 0x00 {
return data[index+4 : endIndex], nil
Expand Down Expand Up @@ -124,7 +124,7 @@ func GetExtensionBlock(data []byte) ([]byte, error) {
}

/* Index is at Cipher List Length bits */
if newIndex := (index + 2 + int((data[index]<<8)+data[index+1])); (newIndex + 1) < len(data) {
if newIndex := (index + 2 + int(data[index])<<8 + data[index+1]); (newIndex + 1) < len(data) {
index = newIndex
} else {
return []byte{}, fmt.Errorf("Not enough bytes for the Cipher List")
Expand Down