aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-05-28 14:41:43 +0000
committerMark Johnston <markj@FreeBSD.org>2021-06-01 20:32:50 +0000
commit4e2e151b2099f3815ef1d170efc727c4b7cec98c (patch)
treeaabc4072adc3388b28d08312cc1c50c06ffbf775
parenta4deddc0de32efbd718f06f01fa7dae1d67d625b (diff)
downloadsrc-4e2e151b2099f3815ef1d170efc727c4b7cec98c.tar.gz
src-4e2e151b2099f3815ef1d170efc727c4b7cec98c.zip
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. Approved by: so Security: FreeBSD-EN-21:17.libradius 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) (cherry picked from commit f9972532343bb1eb101bf7afef2966972eea3b5e)
-rw-r--r--lib/libradius/radlib.c7
1 files changed, 6 insertions, 1 deletions
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;
}