From 722c4939c0026cd0ff8110049468560fbb44d454 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 7 Apr 2017 16:56:51 +0100 Subject: [PATCH] [Minor] Add some more boundaries checks --- src/libserver/spf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libserver/spf.c b/src/libserver/spf.c index f106e534d..dc8e2b36c 100644 --- a/src/libserver/spf.c +++ b/src/libserver/spf.c @@ -424,17 +424,17 @@ spf_check_ptr_host (struct spf_dns_cb *cb, const char *name) const char *dend, *nend, *dstart, *nstart; struct spf_record *rec = cb->rec; - if (name == NULL) { - return FALSE; - } if (cb->ptr_host != NULL) { dstart = cb->ptr_host; - } else { dstart = cb->resolved->cur_domain; } + if (name == NULL || dstart == NULL) { + return FALSE; + } + msg_debug_spf ("check ptr %s vs %s", name, dstart); /* We need to check whether `cur_domain` is a subdomain for `name` */ @@ -442,7 +442,7 @@ spf_check_ptr_host (struct spf_dns_cb *cb, const char *name) nstart = name; nend = nstart + strlen (nstart) - 1; - if (nend == nstart || dend == dstart) { + if (nend <= nstart || dend <= dstart) { return FALSE; } /* Strip last '.' from names */ -- 2.39.5