]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix bugs in packStructValue
authorMichael Hoisie <hoisie@gmail.com>
Sun, 18 Apr 2010 21:46:24 +0000 (14:46 -0700)
committerRuss Cox <rsc@golang.org>
Sun, 18 Apr 2010 21:46:24 +0000 (14:46 -0700)
packStructValue was cutting off last byte of uint32
in _Dns_msg.Unpack, use packRR for rr types

R=rsc
CC=golang-dev
https://golang.org/cl/844048

src/pkg/net/dnsmsg.go

index adedcab99350efb8ac43d87e69c9647d88616362..5091896392d593acaa6d8f9790fd5e3bf062f5c9 100644 (file)
@@ -389,7 +389,7 @@ func packStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int, o
                        msg[off] = byte(i >> 24)
                        msg[off+1] = byte(i >> 16)
                        msg[off+2] = byte(i >> 8)
-                       msg[off+4] = byte(i)
+                       msg[off+3] = byte(i)
                        off += 4
                case *reflect.StringValue:
                        // There are multiple string encodings.
@@ -633,13 +633,13 @@ func (dns *_DNS_Msg) Pack() (msg []byte, ok bool) {
                off, ok = packStruct(&question[i], msg, off)
        }
        for i := 0; i < len(answer); i++ {
-               off, ok = packStruct(answer[i], msg, off)
+               off, ok = packRR(answer[i], msg, off)
        }
        for i := 0; i < len(ns); i++ {
-               off, ok = packStruct(ns[i], msg, off)
+               off, ok = packRR(ns[i], msg, off)
        }
        for i := 0; i < len(extra); i++ {
-               off, ok = packStruct(extra[i], msg, off)
+               off, ok = packRR(extra[i], msg, off)
        }
        if !ok {
                return nil, false