mirror of
https://github.com/AdguardTeam/dnsproxy.git
synced 2026-10-12 02:01:26 +00:00
Pull request #436: AGDNS-4074-limit-reads
Merge in GO/dnsproxy from AGDNS-4074-limit-reads to master Squashed commit of the following: commit 33b1ccdad30a5524aa4c871d3fad5f163701d5b2 Author: f.setrakov <[email protected]> Date: Wed Jun 3 14:58:26 2026 +0300 all: limit reads
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/AdguardTeam/dnsproxy/internal/bootstrap"
|
||||
"github.com/AdguardTeam/golibs/httphdr"
|
||||
"github.com/AdguardTeam/golibs/ioutil"
|
||||
"github.com/AdguardTeam/golibs/logutil/slogutil"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/quic-go/quic-go"
|
||||
@@ -159,8 +160,8 @@ func newDoHReq(
|
||||
return nil, http.StatusUnsupportedMediaType
|
||||
}
|
||||
|
||||
// TODO(d.kolyshev): Limit reader.
|
||||
buf, err = io.ReadAll(r.Body)
|
||||
limitBody := ioutil.LimitReader(r.Body, dns.MaxMsgSize)
|
||||
buf, err = io.ReadAll(limitBody)
|
||||
if err != nil {
|
||||
l.DebugContext(ctx, "reading http request body", slogutil.KeyError, err)
|
||||
|
||||
|
||||
+3
-1
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/AdguardTeam/dnsproxy/internal/bootstrap"
|
||||
"github.com/AdguardTeam/golibs/errors"
|
||||
"github.com/AdguardTeam/golibs/httphdr"
|
||||
"github.com/AdguardTeam/golibs/ioutil"
|
||||
"github.com/AdguardTeam/golibs/logutil/slogutil"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/quic-go/quic-go"
|
||||
@@ -288,7 +289,8 @@ func (p *dnsOverHTTPS) exchangeHTTPSClient(
|
||||
}
|
||||
defer slogutil.CloseAndLog(httpReq.Context(), p.logger, httpResp.Body, slog.LevelDebug)
|
||||
|
||||
body, err := io.ReadAll(httpResp.Body)
|
||||
limitBody := ioutil.LimitReader(httpResp.Body, dns.MaxMsgSize)
|
||||
body, err := io.ReadAll(limitBody)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("reading %s: %w", p.addrRedacted, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user