[net] dns/dnsmessage: return an error for too long SVCParam.Value

3 views
Skip to first unread message

Mateusz Poliwczak (Gerrit)

unread,
12:26 PM (11 hours ago) 12:26 PM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Mateusz Poliwczak has uploaded the change for review

Commit message

dns/dnsmessage: return an error for too long SVCParam.Value

Updates #43790
Change-Id: Id9f5bdc3e17a6f7d2c9b7b8a4e48c0c66a6a6964

Change diff

diff --git a/dns/dnsmessage/message.go b/dns/dnsmessage/message.go
index 3969222..7a978b4 100644
--- a/dns/dnsmessage/message.go
+++ b/dns/dnsmessage/message.go
@@ -291,6 +291,7 @@
errNonCanonicalName = errors.New("name is not in canonical format (it must end with a .)")
errStringTooLong = errors.New("character string exceeds maximum length (255)")
errParamOutOfOrder = errors.New("parameter out of order")
+ errTooLongSVCBValue = errors.New("value too long (>65535 bytes)")
)

// Internal constants.
diff --git a/dns/dnsmessage/svcb.go b/dns/dnsmessage/svcb.go
index 21ba45d..635e751 100644
--- a/dns/dnsmessage/svcb.go
+++ b/dns/dnsmessage/svcb.go
@@ -5,6 +5,7 @@
package dnsmessage

import (
+ "math"
"slices"
"strings"
)
@@ -171,6 +172,9 @@
if i > 0 && param.Key <= previousKey {
return oldMsg, &nestedError{"SVCBResource.Params", errParamOutOfOrder}
}
+ if len(param.Value) > math.MaxUint16 {
+ return oldMsg, &nestedError{"SVCBResource.Params", errTooLongSVCBValue}
+ }
msg = packUint16(msg, uint16(param.Key))
msg = packUint16(msg, uint16(len(param.Value)))
msg = append(msg, param.Value...)
diff --git a/dns/dnsmessage/svcb_test.go b/dns/dnsmessage/svcb_test.go
index 6b49f0c..74fcccd 100644
--- a/dns/dnsmessage/svcb_test.go
+++ b/dns/dnsmessage/svcb_test.go
@@ -6,6 +6,7 @@

import (
"bytes"
+ "math"
"reflect"
"testing"
)
@@ -364,3 +365,29 @@
}
testRecord(bytes, parsed)
}
+
+func TestSVCBPackLongValue(t *testing.T) {
+ b := NewBuilder(nil, Header{})
+ b.StartQuestions()
+ b.StartAnswers()
+
+ res := SVCBResource{
+ Target: MustNewName("example.com."),
+ Params: []SVCParam{
+ {
+ Key: SVCParamMandatory,
+ Value: make([]byte, math.MaxUint16+1),
+ },
+ },
+ }
+
+ err := b.SVCBResource(ResourceHeader{Name: MustNewName("example.com.")}, res)
+ if err == nil || err.Error() != "ResourceBody: SVCBResource.Params: value too long (>65535 bytes)" {
+ t.Fatalf(`b.SVCBResource() = %v; want = "ResourceBody: SVCBResource.Params: value too long (>65535 bytes)"`, err)
+ }
+
+ err = b.HTTPSResource(ResourceHeader{Name: MustNewName("example.com.")}, HTTPSResource{res})
+ if err == nil || err.Error() != "ResourceBody: SVCBResource.Params: value too long (>65535 bytes)" {
+ t.Fatalf(`b.HTTPSResource() = %v; want = "ResourceBody: SVCBResource.Params: value too long (>65535 bytes)"`, err)
+ }
+}

Change information

Files:
  • M dns/dnsmessage/message.go
  • M dns/dnsmessage/svcb.go
  • M dns/dnsmessage/svcb_test.go
Change size: S
Delta: 3 files changed, 32 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: net
Gerrit-Branch: master
Gerrit-Change-Id: Id9f5bdc3e17a6f7d2c9b7b8a4e48c0c66a6a6964
Gerrit-Change-Number: 712080
Gerrit-PatchSet: 1
Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Mateusz Poliwczak (Gerrit)

unread,
12:26 PM (11 hours ago) 12:26 PM
to goph...@pubsubhelper.golang.org, Damien Neil, Vinicius Fortuna, golang-co...@googlegroups.com
Attention needed from Damien Neil

Mateusz Poliwczak voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: net
Gerrit-Branch: master
Gerrit-Change-Id: Id9f5bdc3e17a6f7d2c9b7b8a4e48c0c66a6a6964
Gerrit-Change-Number: 712080
Gerrit-PatchSet: 1
Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Mateusz Poliwczak <mpoliw...@gmail.com>
Gerrit-CC: Vinicius Fortuna <for...@google.com>
Gerrit-Attention: Damien Neil <dn...@google.com>
Gerrit-Comment-Date: Wed, 15 Oct 2025 16:26:38 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Vinicius Fortuna (Gerrit)

unread,
1:58 PM (10 hours ago) 1:58 PM
to Mateusz Poliwczak, goph...@pubsubhelper.golang.org, Go LUCI, Damien Neil, golang-co...@googlegroups.com
Attention needed from Damien Neil and Mateusz Poliwczak

Vinicius Fortuna voted and added 1 comment

Votes added by Vinicius Fortuna

Code-Review+1

1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Vinicius Fortuna . resolved

Nice addition. Thanks for the fix!

Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
  • Mateusz Poliwczak
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: net
    Gerrit-Branch: master
    Gerrit-Change-Id: Id9f5bdc3e17a6f7d2c9b7b8a4e48c0c66a6a6964
    Gerrit-Change-Number: 712080
    Gerrit-PatchSet: 1
    Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Mateusz Poliwczak <mpoliw...@gmail.com>
    Gerrit-Reviewer: Vinicius Fortuna <for...@google.com>
    Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 17:58:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Sean Liao (Gerrit)

    unread,
    4:28 PM (7 hours ago) 4:28 PM
    to Mateusz Poliwczak, goph...@pubsubhelper.golang.org, Vinicius Fortuna, Go LUCI, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Damien Neil and Mateusz Poliwczak

    Sean Liao voted Code-Review+2

    Code-Review+2
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Mateusz Poliwczak
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: net
    Gerrit-Branch: master
    Gerrit-Change-Id: Id9f5bdc3e17a6f7d2c9b7b8a4e48c0c66a6a6964
    Gerrit-Change-Number: 712080
    Gerrit-PatchSet: 1
    Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Mateusz Poliwczak <mpoliw...@gmail.com>
    Gerrit-Reviewer: Sean Liao <se...@liao.dev>
    Gerrit-Reviewer: Vinicius Fortuna <for...@google.com>
    Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 20:28:41 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Damien Neil (Gerrit)

    unread,
    5:02 PM (7 hours ago) 5:02 PM
    to Mateusz Poliwczak, goph...@pubsubhelper.golang.org, Vinicius Fortuna, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Mateusz Poliwczak

    Damien Neil voted and added 1 comment

    Votes added by Damien Neil

    Auto-Submit+1
    Code-Review+2

    1 comment

    Patchset-level comments
    Damien Neil . resolved

    Thanks!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mateusz Poliwczak
    Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: net
      Gerrit-Branch: master
      Gerrit-Change-Id: Id9f5bdc3e17a6f7d2c9b7b8a4e48c0c66a6a6964
      Gerrit-Change-Number: 712080
      Gerrit-PatchSet: 1
      Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Reviewer: Sean Liao <se...@liao.dev>
      Gerrit-Reviewer: Vinicius Fortuna <for...@google.com>
      Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Comment-Date: Wed, 15 Oct 2025 21:02:41 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Gopher Robot (Gerrit)

      unread,
      5:03 PM (7 hours ago) 5:03 PM
      to Mateusz Poliwczak, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Damien Neil, Vinicius Fortuna, Go LUCI, golang-co...@googlegroups.com

      Gopher Robot submitted the change

      Change information

      Commit message:
      dns/dnsmessage: return an error for too long SVCParam.Value

      Updates #43790
      Change-Id: Id9f5bdc3e17a6f7d2c9b7b8a4e48c0c66a6a6964
      Auto-Submit: Damien Neil <dn...@google.com>
      Reviewed-by: Damien Neil <dn...@google.com>
      Reviewed-by: Vinicius Fortuna <for...@google.com>
      Reviewed-by: Sean Liao <se...@liao.dev>
      Files:
      • M dns/dnsmessage/message.go
      • M dns/dnsmessage/svcb.go
      • M dns/dnsmessage/svcb_test.go
      Change size: S
      Delta: 3 files changed, 32 insertions(+), 0 deletions(-)
      Branch: refs/heads/master
      Submit Requirements:
      • requirement satisfiedCode-Review: +2 by Damien Neil, +1 by Vinicius Fortuna, +2 by Sean Liao
      • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: net
      Gerrit-Branch: master
      Gerrit-Change-Id: Id9f5bdc3e17a6f7d2c9b7b8a4e48c0c66a6a6964
      Gerrit-Change-Number: 712080
      Gerrit-PatchSet: 2
      Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages