mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 13:21:22 +00:00
lib: improve sanity checks in stream_set_endp()
* lib/stream.c: (stream_set_endp) Add checks to make sure that the supplied 'endp' is within the 'size' of the stream, and that the current read pointer 'getp' is not beyond the specified 'endp'.
This commit is contained in:
parent
b4154c145a
commit
4effc29fb1
14
lib/stream.c
14
lib/stream.c
@ -219,13 +219,23 @@ stream_set_endp (struct stream *s, size_t pos)
|
|||||||
{
|
{
|
||||||
STREAM_VERIFY_SANE(s);
|
STREAM_VERIFY_SANE(s);
|
||||||
|
|
||||||
if (!GETP_VALID (s, pos))
|
if (!ENDP_VALID(s, pos))
|
||||||
{
|
{
|
||||||
STREAM_BOUND_WARN (s, "set endp");
|
STREAM_BOUND_WARN (s, "set endp");
|
||||||
pos = s->endp;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the current read pointer is not beyond the new endp.
|
||||||
|
*/
|
||||||
|
if (s->getp > pos)
|
||||||
|
{
|
||||||
|
STREAM_BOUND_WARN(s, "set endp");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->endp = pos;
|
s->endp = pos;
|
||||||
|
STREAM_VERIFY_SANE(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Forward pointer. */
|
/* Forward pointer. */
|
||||||
|
Loading…
Reference in New Issue
Block a user