summaryrefslogtreecommitdiffhomepage
path: root/rfc1035label
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2023-02-25 21:16:36 -0800
committerChris K <c@chrisko.ch>2023-02-27 10:35:19 -0800
commit7698adce8e9cb94d210c31c81591c9c158339b31 (patch)
tree5348de31f9977cfe6aa3635a96989da76e9f3659 /rfc1035label
parent667e3a9e71512220079a51820d57f9e20e9194db (diff)
DomainSearchList: tests for FromBytes, ToBytes, and Getter
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'rfc1035label')
-rw-r--r--rfc1035label/label.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/rfc1035label/label.go b/rfc1035label/label.go
index 042c17b..f727ec6 100644
--- a/rfc1035label/label.go
+++ b/rfc1035label/label.go
@@ -89,6 +89,10 @@ func FromBytes(data []byte) (*Labels, error) {
return &l, nil
}
+// ErrBufferTooShort is returned when the label cannot be parsed due to a wrong
+// length or missing bytes.
+var ErrBufferTooShort = errors.New("rfc1035label: buffer too short")
+
// fromBytes decodes a serialized stream and returns a list of labels
func labelsFromBytes(buf []byte) ([]string, error) {
var (
@@ -132,7 +136,7 @@ func labelsFromBytes(buf []byte) ([]string, error) {
pos = off
} else {
if pos+length > len(buf) {
- return nil, errors.New("rfc1035label: buffer too short")
+ return nil, ErrBufferTooShort
}
chunk = string(buf[pos : pos+length])
if label != "" {