summaryrefslogtreecommitdiffhomepage
path: root/rfc1035label/label.go
diff options
context:
space:
mode:
Diffstat (limited to 'rfc1035label/label.go')
-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 != "" {