Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 May 2021 17:01:30 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: dbb3df26a8a3 - stable/11 - libradius: Fix attribute length validation in rad_get_attr(3)
Message-ID:  <202105281701.14SH1UZJ020326@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/11 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=dbb3df26a8a3e1343b42844a6a6e3e9adf49ca8c

commit dbb3df26a8a3e1343b42844a6a6e3e9adf49ca8c
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-05-28 14:41:43 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-05-28 17:00:37 +0000

    libradius: Fix attribute length validation in rad_get_attr(3)
    
    The length of the attribute header needs to be excluded when comparing
    the attribute length against the length of the packet.  Otherwise,
    validation may incorrectly fail when fetching the final attribute in a
    message.
    
    Fixes:          8d5c78130 ("libradius: Fix input validation bugs")
    Reported by:    Peter Eriksson
    Tested by:      Peter Eriksson
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 6bb5699d2b59491097bc21ffa3c097cdd4853f89)
---
 lib/libradius/radlib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c
index acca95da6f66..e679b95089b0 100644
--- a/lib/libradius/radlib.c
+++ b/lib/libradius/radlib.c
@@ -949,7 +949,12 @@ rad_get_attr(struct rad_handle *h, const void **value, size_t *lenp)
 	}
 	type = h->in[h->in_pos++];
 	len = h->in[h->in_pos++];
-	if (len < 2 || h->in_pos + len > h->in_len) {
+	if (len < 2) {
+		generr(h, "Malformed attribute in response");
+		return -1;
+	}
+	len -= 2;
+	if (h->in_pos + len > h->in_len) {
 		generr(h, "Malformed attribute in response");
 		return -1;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105281701.14SH1UZJ020326>