UnpackDomainName: fix infinite loop where it would lower 'off'

When a pointer points to a empty name, the "return '.'" special case used to
kick in which is not pointer-aware so it would reset the parsing offset to
the pointer target

This was independently found and fixed in c13d4ee, I'm submitting this patch
anyway as it seems a bit more robust and DRY [citation needed].
This commit is contained in:
Filippo Valsorda 2015-08-05 00:18:02 +01:00
parent 77aa064ef9
commit 2b564cd047
1 changed files with 3 additions and 6 deletions

9
msg.go
View File

@ -413,12 +413,6 @@ Loop:
case 0x00:
if c == 0x00 {
// end of name
if len(s) == 0 {
if ptr == 0 {
off1 = off
}
return ".", off1, nil
}
break Loop
}
// literal string
@ -479,6 +473,9 @@ Loop:
if ptr == 0 {
off1 = off
}
if len(s) == 0 {
s = []byte(".")
}
return string(s), off1, nil
}