-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RFC 2136: Dynamic updates #1513
Comments
this little test shows that all defined RRs parse correctly and give back an RR with RDLENGTH set to 0 package dns
import (
"sort"
"testing"
)
func TestUpdate2NoRdata(t *testing.T) {
ex := "example.org. IN "
types := sort.IntSlice{}
for i := range TypeToString {
types = append(types, int(i))
}
types.Sort()
for _, ty := range types {
if uint16(ty) == TypeNone || uint16(ty) == TypeReserved {
continue
}
name := TypeToString[uint16(ty)]
str := ex + name
rr, err := NewRR(str)
if err != nil {
t.Fatalf("Failed to parse %s: %s", str, err)
}
t.Logf("%s => %#v", str, rr)
}
} |
packing also works func TestUpdate2NoRdataPack(t *testing.T) {
types := sort.IntSlice{}
for i := range TypeToString {
types = append(types, int(i))
}
types.Sort()
for _, ty := range types {
if uint16(ty) == TypeNone || uint16(ty) == TypeReserved {
continue
}
m := new(Msg)
if _, ok := TypeToRR[uint16(ty)]; !ok {
t.Logf("no new function for %s", TypeToString[uint16(ty)])
continue
}
rr := TypeToRR[uint16(ty)]()
rr.Header().Name = "example.org."
rr.Header().Rrtype = uint16(ty)
m.Answer = []RR{rr}
t.Logf("msg: %s\n", m)
_, err := m.Pack()
if err != nil {
t.Fatalf("error packing expected msg: %v", err)
}
}
} With the few RR that don't have an actual type:
(and maybe a few other that I forgot) |
Adding diff --git msg_helpers.go msg_helpers.go
index acec21f7..270be228 100644
--- msg_helpers.go
+++ msg_helpers.go
@@ -202,6 +202,11 @@ func packUint16(i uint16, msg []byte, off int) (off1 int, err error) {
}
func unpackUint32(msg []byte, off int) (i uint32, off1 int, err error) {
+ // for dynamic update purposes this uint32 may not be there
+ println(off, len(msg))
+ if off+1 == len(msg) {
+ return 0, off, nil
+ }
if off+4 > len(msg) {
return 0, len(msg), &Error{err: "overflow unpacking uint32"} this prints:
so This hints in a problem with the packing. Making that a
|
https://datatracker.ietf.org/doc/html/rfc2136
These are normal RRs where the RDATA is cut off, CLASS is not important here.
This issue will detail how to make those and where this lib currently fails to do so (or for which RR types)
NewRR
into RR with rdlenght=0TestNoRdataUnpack
- off-by-one error in unpack/pack somewhereThe text was updated successfully, but these errors were encountered: