diff options
author | Michael Hoisie <hoisie@gmail.com> | 2010-04-18 14:46:24 -0700 |
---|---|---|
committer | Michael Hoisie <hoisie@gmail.com> | 2010-04-18 14:46:24 -0700 |
commit | 90d447a14df68497f355a20e8816aa221dd1208c (patch) | |
tree | 76fb70873d0de3b406cbe873895300e616c91b69 | |
parent | 8e87e685b81a225e533d1269c972bd0131971454 (diff) | |
download | golang-90d447a14df68497f355a20e8816aa221dd1208c.tar.gz |
net: fix bugs in packStructValue
packStructValue was cutting off last byte of uint32
in _Dns_msg.Unpack, use packRR for rr types
R=rsc
CC=golang-dev
http://codereview.appspot.com/844048
Committer: Russ Cox <rsc@golang.org>
-rw-r--r-- | src/pkg/net/dnsmsg.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/net/dnsmsg.go b/src/pkg/net/dnsmsg.go index adedcab99..509189639 100644 --- a/src/pkg/net/dnsmsg.go +++ b/src/pkg/net/dnsmsg.go @@ -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 |