mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-05 14:17:36 +03:00
Update deps
This commit is contained in:
parent
d627a4bc58
commit
d2db6b55a8
187 changed files with 15865 additions and 3125 deletions
26
vendor/github.com/miekg/dns/msg_helpers.go
generated
vendored
26
vendor/github.com/miekg/dns/msg_helpers.go
generated
vendored
|
@ -265,24 +265,36 @@ func unpackString(msg []byte, off int) (string, int, error) {
|
|||
return "", off, &Error{err: "overflow unpacking txt"}
|
||||
}
|
||||
l := int(msg[off])
|
||||
if off+l+1 > len(msg) {
|
||||
off++
|
||||
if off+l > len(msg) {
|
||||
return "", off, &Error{err: "overflow unpacking txt"}
|
||||
}
|
||||
var s strings.Builder
|
||||
s.Grow(l)
|
||||
for _, b := range msg[off+1 : off+1+l] {
|
||||
consumed := 0
|
||||
for i, b := range msg[off : off+l] {
|
||||
switch {
|
||||
case b == '"' || b == '\\':
|
||||
if consumed == 0 {
|
||||
s.Grow(l * 2)
|
||||
}
|
||||
s.Write(msg[off+consumed : off+i])
|
||||
s.WriteByte('\\')
|
||||
s.WriteByte(b)
|
||||
consumed = i + 1
|
||||
case b < ' ' || b > '~': // unprintable
|
||||
if consumed == 0 {
|
||||
s.Grow(l * 2)
|
||||
}
|
||||
s.Write(msg[off+consumed : off+i])
|
||||
s.WriteString(escapeByte(b))
|
||||
default:
|
||||
s.WriteByte(b)
|
||||
consumed = i + 1
|
||||
}
|
||||
}
|
||||
off += 1 + l
|
||||
return s.String(), off, nil
|
||||
if consumed == 0 { // no escaping needed
|
||||
return string(msg[off : off+l]), off + l, nil
|
||||
}
|
||||
s.Write(msg[off+consumed : off+l])
|
||||
return s.String(), off + l, nil
|
||||
}
|
||||
|
||||
func packString(s string, msg []byte, off int) (int, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue