Commit 9eda2b99 authored by Rémy Oudompheng's avatar Rémy Oudompheng

net: do not use reflect for DNS messages.

Fixes #3201.

R=bradfitz, bradfitz, rsc
CC=golang-dev, remy
https://golang.org/cl/5753045
parent 9442c442
......@@ -226,8 +226,8 @@ var pkgDeps = map[string][]string{
"os/user": {"L3", "CGO", "syscall"},
// Basic networking.
// TODO: Remove reflect, possibly math/rand.
"net": {"L0", "CGO", "math/rand", "os", "reflect", "sort", "syscall", "time"},
// TODO: maybe remove math/rand.
"net": {"L0", "CGO", "math/rand", "os", "sort", "syscall", "time"},
// NET enables use of basic network-related packages.
"NET": {
......
This diff is collapsed.
......@@ -6,6 +6,7 @@ package net
import (
"encoding/hex"
"reflect"
"testing"
)
......@@ -39,6 +40,16 @@ func TestDNSParseSRVReply(t *testing.T) {
t.Errorf("len(addrs) = %d; want %d", g, e)
t.Logf("addrs = %#v", addrs)
}
// repack and unpack.
data2, ok := msg.Pack()
msg2 := new(dnsMsg)
msg2.Unpack(data2)
switch {
case !ok:
t.Errorf("failed to repack message")
case !reflect.DeepEqual(msg, msg2):
t.Errorf("repacked message differs from original")
}
}
func TestDNSParseCorruptSRVReply(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment