git » spf » commit 525938d

ptr, redirect: Forbid empty domains

author Alberto Bertogli
2019-10-14 01:39:56 UTC
committer Alberto Bertogli
2019-10-14 12:35:29 UTC
parent bb0482032d3e273e578abca2b482d086c8e684a6

ptr, redirect: Forbid empty domains

Both ptr and redirect records are not allowed to have an empty domain,
this patch enforces that requirement.

Found by the standard test suite.

spf.go +8 -0

diff --git a/spf.go b/spf.go
index 45139ea..5716cad 100644
--- a/spf.go
+++ b/spf.go
@@ -359,6 +359,10 @@ func (r *resolution) ptrField(res Result, field, domain string) (bool, Result, e
 		return true, PermError, errInvalidMacro
 	}
 
+	if ptrDomain == "" {
+		return true, PermError, errInvalidDomain
+	}
+
 	if r.ipNames == nil {
 		r.count++
 		n, err := lookupAddr(r.ip.String())
@@ -599,6 +603,10 @@ func (r *resolution) redirectField(field, domain string) (Result, error) {
 		return PermError, errInvalidMacro
 	}
 
+	if rDomain == "" {
+		return PermError, errInvalidDomain
+	}
+
 	// https://tools.ietf.org/html/rfc7208#section-6.1
 	result, err := r.Check(rDomain)
 	if result == None {