Skip to content

Commit

Permalink
Merge pull request #254 from DataDog/anthony.lam/domain-namelen-error
Browse files Browse the repository at this point in the history
[backend] Modify domain name length error
  • Loading branch information
AyyLam committed Jun 8, 2023
2 parents 1e7b2fc + b5787c4 commit 839e291
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions process/dns_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,13 @@ func getDNSNameAsByteSliceByOffset(buf []byte, offset int) (stringasbyteslice []
if offset+int(namelen) > len(buf) {
return nil, fmt.Errorf("offset out of range [%d:%d] > %d", offset, offset+int(namelen), len(buf))
}

// For when the domain name is an empty string
if namelen == 0 {
return nil, fmt.Errorf("illegal domain namelen of 0")
}
if offset+int(namelen) <= offset {
return nil, fmt.Errorf("illegal namelen")
return nil, fmt.Errorf("integer overflow from domain name length: (%d+%d) <= %d", offset, int(namelen), offset)
}

return buf[offset : offset+int(namelen)], nil
}

Expand Down

0 comments on commit 839e291

Please sign in to comment.