mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-07 00:50:50 +00:00
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
This commit is contained in:
parent
5434ebd256
commit
6bb5699d2b
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue