mirror of
https://github.com/golang/net.git
synced 2026-04-01 02:47:08 +09:00
bytes -> bits typo
This commit is contained in:
@@ -2000,7 +2000,7 @@ func (n *Name) pack(msg []byte, compression map[string]int, compressionOff int)
|
||||
}
|
||||
|
||||
// Miss. Add the suffix to the compression table if the
|
||||
// offset can be stored in the available 14 bytes.
|
||||
// offset can be stored in the available 14 bits.
|
||||
newPtr := len(msg) - compressionOff
|
||||
if newPtr <= int(^uint16(0)>>2) {
|
||||
if nameAsStr == "" {
|
||||
@@ -2008,7 +2008,7 @@ func (n *Name) pack(msg []byte, compression map[string]int, compressionOff int)
|
||||
// multiple times (for next labels).
|
||||
nameAsStr = string(n.Data[:n.Length])
|
||||
}
|
||||
compression[string(n.Data[i:])] = newPtr
|
||||
compression[nameAsStr[i:]] = newPtr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1820,20 +1820,24 @@ func TestBuilderNameCompressionWithNonZeroedName(t *testing.T) {
|
||||
if err := b.StartQuestions(); err != nil {
|
||||
t.Fatalf("b.StartQuestions() unexpected error: %v", err)
|
||||
}
|
||||
|
||||
name := MustNewName("go.dev.")
|
||||
if err := b.Question(Question{Name: name}); err != nil {
|
||||
t.Fatalf("b.Question() unexpected error: %v", err)
|
||||
}
|
||||
|
||||
// Character that is not part of the name (name.Data[:name.Length]),
|
||||
// shouldn't affect the compression algorithm.
|
||||
name.Data[name.Length] = '1'
|
||||
if err := b.Question(Question{Name: name}); err != nil {
|
||||
t.Fatalf("b.Question() unexpected error: %v", err)
|
||||
}
|
||||
|
||||
msg, err := b.Finish()
|
||||
if err != nil {
|
||||
t.Fatalf("b.Finish() unexpected error: %v", err)
|
||||
}
|
||||
|
||||
expect := []byte{
|
||||
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, // header
|
||||
2, 'g', 'o', 3, 'd', 'e', 'v', 0, 0, 0, 0, 0, // question 1
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
go test fuzz v1
|
||||
[]byte("0000\x00\x01\x00\x00\x00\x01\x00\x00\x000000\x01.\x0000000000\x00\x040000")
|
||||
@@ -1,2 +0,0 @@
|
||||
go test fuzz v1
|
||||
[]byte("0000\x00\x01\x00\x00\x00\x00\x00\x00\x01.\x000000")
|
||||
Reference in New Issue
Block a user