git: 6bb5699d2b59 - main - libradius: Fix attribute length validation in rad_get_attr(3)
Mark Johnston
markj at FreeBSD.org
Fri May 28 16:59:38 UTC 2021
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=6bb5699d2b59491097bc21ffa3c097cdd4853f89
commit 6bb5699d2b59491097bc21ffa3c097cdd4853f89
Author: Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-05-28 14:41:43 +0000
Commit: Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-05-28 16:58:29 +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
MFC after: now
Sponsored by: The FreeBSD Foundation
---
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 18aee8b53024..4d21887c4ee2 100644
--- a/lib/libradius/radlib.c
+++ b/lib/libradius/radlib.c
@@ -964,7 +964,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;
}
More information about the dev-commits-src-main
mailing list